From c01487347d9e4c81555ec6a5ad8f5f04847319ab Mon Sep 17 00:00:00 2001 From: Jeremy Latt Date: Tue, 17 Apr 2012 18:49:14 -0700 Subject: [PATCH] reorganize constants --- src/irc/constants.go | 25 +++++++++++++++ src/irc/protocol.go | 74 -------------------------------------------- 2 files changed, 25 insertions(+), 74 deletions(-) create mode 100644 src/irc/constants.go diff --git a/src/irc/constants.go b/src/irc/constants.go new file mode 100644 index 00000000..9c3a637e --- /dev/null +++ b/src/irc/constants.go @@ -0,0 +1,25 @@ +// http://tools.ietf.org/html/rfc2812 +package irc + +const ( + VERSION = "goircd-1" +) + +const ( + RPL_WELCOME = "001" + RPL_YOURHOST = "002" + RPL_CREATED = "003" + RPL_MYINFO = "004" + RPL_NONE = "300" +) + +const ( + ERR_NOSUCHNICK = "401" + ERR_NOSUCHSERVER = "402" + ERR_NOSUCHCHANNEL = "403" + ERR_UNKNOWNCOMMAND = "421" + ERR_NICKNAMEINUSE = "433" + ERR_NEEDMOREPARAMS = "461" + ERR_ALREADYREGISTRED = "462" + ERR_USERSDONTMATCH = "502" +) diff --git a/src/irc/protocol.go b/src/irc/protocol.go index 894ba02c..c9710692 100644 --- a/src/irc/protocol.go +++ b/src/irc/protocol.go @@ -1,22 +1,9 @@ -// http://tools.ietf.org/html/rfc2812 package irc import ( "fmt" ) -const ( - VERSION = "goircd-1" -) - -const ( - RPL_WELCOME = "001" - RPL_YOURHOST = "002" - RPL_CREATED = "003" - RPL_MYINFO = "004" - RPL_NONE = "300" -) - func ReplyWelcome(nick string, user string, host string) string { return fmt.Sprintf("%s %s Welcome to the Internet Relay Network %s!%s@%s", RPL_WELCOME, nick, nick, user, host) } @@ -33,17 +20,6 @@ func ReplyMyInfo(nick string, servername string) string { return fmt.Sprintf("%s %s %s %s ", RPL_MYINFO, nick, servername, VERSION) } -const ( - ERR_NOSUCHNICK = "401" - ERR_NOSUCHSERVER = "402" - ERR_NOSUCHCHANNEL = "403" - ERR_UNKNOWNCOMMAND = "421" - ERR_NICKNAMEINUSE = "433" - ERR_NEEDMOREPARAMS = "461" - ERR_ALREADYREGISTRED = "462" - ERR_USERSDONTMATCH = "502" -) - func ErrAlreadyRegistered(nick string) string { return fmt.Sprintf("%s %s :You may not reregister", ERR_ALREADYREGISTRED, nick) } @@ -56,56 +32,6 @@ func ErrUnknownCommand(nick string, command string) string { return fmt.Sprintf("%s %s %s :Unknown command", ERR_UNKNOWNCOMMAND, nick, command) } - -const ( - RE_PASS = "(?P\\S+)" - RE_NICK = "(?P\\S+)" - RE_USER = "(?P\\S+) (?P\\d) (?:\\S+) :(?P.+)" - RE_OPER = "(?P\\S+) (?P\\S+)" - RE_MODE = "(?P\\S+)(?: (?P[-+][iwroOs]+))*" - RE_SERVICE = "(?P\\S+) (?P\\S+) (?P\\S+) (?P\\S+) (?P\\S+) :(?P.+)" - RE_QUIT = ":(?P.*)" - RE_SQUIT = "(?P\\S+) :(?P.+)" - RE_JOIN = "0|(?:(?P\\S+(?:,\\S+)*)(?: (?P\\S+(?:,\\S+)*))?)" - RE_PART = "(?P\\S+(?:,\\S+)*)(?: :(?P.+))?" - RE_MODE_CH = "(?P\\S+)(?: (?P[-+][iwroOs]+))*" // XXX incomplete - RE_TOPIC = "(?P\\S+)(?: :(?P.+))?" - RE_NAMES = "(?:(?P\\S+(?:,\\S+)*)(?: (?P\\S+))?)?" - RE_LIST = "(?:(?P\\S+(?:,\\S+)*)(?: (?P\\S+))?)?" - RE_INVITE = "(?P\\S+) (?P\\S+)" - RE_KICK = "(?P\\S+(?:,\\S+)*) (?P\\S+(?:,\\S+))(?: :(?P.+))?" - RE_PRIVMSG = "(?P\\S+) :(?P.+)" - RE_NOTICE = "(?P\\S+) :(?P.+)" - RE_MOTD = "(?P\\S+)?" - RE_LUSERS = "(?:(?P\\S+)(?: (?P\\S+))?)?" - RE_VERSION = "(?P\\S+)?" - RE_STATS = "(?:(?P\\S+)(?: (?P\\S+))?)?" - RE_LINKS = "(?:(?P\\S+) )?(?P\\S+)" - RE_TIME = "(?P\\S+)?" - RE_CONNECT = "(?P\\S+) (?P\\d+)(?: (?P\\S+))?" - RE_TRACE = "(?P\\S+)?" - RE_ADMIN = "(?P\\S+)?" - RE_INFO = "(?P\\S+)?" - RE_SERVLIST = "" // XXX - RE_SQUERY = "" // XXX - RE_WHO = "" // XXX - RE_WHOIS = "" // XXX - RE_WHOWAS = "" // XXX - RE_KILL = "(?P\\S+) :(?P.+)" - RE_PING = "(?P\\S+)(?: (?P\\S+))?" - RE_PONG = "(?P\\S+)(?: (?P\\S+))?" - RE_ERROR = ":(?P.+)" - RE_AWAY = ":(?P.+)" - RE_REHASH = "" - RE_DIE = "" - RE_RESTART = "" - RE_SUMMON = "(?P\\S+)(?: (?P\\S+)(?: (?P\\S+))?)?" - RE_USERS = "(?P\\S+)?" - RE_WALLOPS = ":(?P.+)" - RE_USERHOST = "(?P\\S+(?: \\S+)*)" - RE_ISON = "(?P\\S+(?: \\S+)*)" -) - func MessagePong() string { return "PONG" }