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) } func ReplyYourHost(nick string, server string) string { return fmt.Sprintf("%s %s Your host is %s, running version %s", RPL_YOURHOST, nick, server, VERSION) } func ReplyCreated(nick string, created string) string { return fmt.Sprintf("%s %s This server was created %s", RPL_CREATED, nick, created) } 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) } func ErrNickNameInUse(nick string) string { return fmt.Sprintf("%s %s :Nickname is already in use", ERR_NICKNAMEINUSE, nick) } 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" } func MessageError() string { return "ERROR :Bye" }