RFC文档肯定没用! 您是正确的,您需要发送USER
然后发送NICK
。 您收到的NOTICE
是IRC服务器正在尝试通过名为IDENTD
的协议连接回您的PC。 这是一个相对简单的协议,但它的结果是它想知道连接到服务器的主机上的程序正在使用服务器具有的本地/远程端口。
有可能,您的防火墙正在阻止这种情况(您可能没有运行IDENTD服务器)。 这不是一个大问题,尽管一个成熟的IRC客户端将实现它。 你可以在这里找到更多。 这更详细。 实施起来相对简单。
大多数IRC服务器都会放弃,如果它无法连接到你,我已经忘记了它的确切 副作用(它已经有一段时间了),但你想要注意的下一条消息是MOTD_START / MOTD / MOTD_END和ERR_NOMOTD。 只有在 收到当天消息的结尾或处理了ERR_NOMOTD(没有一个)之后,才能使用JOIN
加入频道。
顺便提一下,这是一个很好的RegEx,用于匹配来自IRC服务器的输入:
^(?:[:@]([^\\s]+) )?([^\\s]+)(?: ((?:[^:\\s][^\\s]* ?)*))?(?: ?:(.*))?$
IRC RFC列出了所有可能的代码及其含义。 我不确定你为什么认为它们没用。 你引用了哪些?
编辑
我查找了用于IRC的旧C ++代码,因此我可以提供更多帮助。 连接后,它进入一个阶段(我已经标记)谈判:
谈判阶段:
如果已为服务器指定了密码,请将其发送给PASS mypassword
。
发送USER
命令。
输入Negotiate Nickname Stage
等待ERR_NOMOTD
, END_OFMOTD
。 直到其中一个出现,你才“正式联系”。
谈判昵称阶段:
完全可能在连接期间,您要使用的昵称已被使用。 因此,客户应该:
发出NICK
命令
如果收到ERR_NICKINUSE
响应,请再次发出。 如果您没有更多的昵称可供使用,您可以拯救或提示用户另一个昵称。
还有一些需要考虑的事情:
查看我们的PING
命令。 当您闲置时,服务器将发送此信息。 将此处理为高优先级,并使用服务器提供的数据返回PONG
。 如果不这样做将确保您断开连接,当您测试IRC客户端时,这可能是后端的痛苦。
奖金乐趣
这是我对IRC命令的枚举,你应该能够很容易地把它放到C#中:
// reply ids enum Reply { RplNone = 0, // Initial RplWelcome = 001, // :Welcome to the Internet Relay Network RplYourHost = 002, // :Your host is , running version RplCreated = 003, // :This server was created RplMyInfo = 004, // RplMap = 005, // :map RplEndOfMap = 007, // :End of /MAP RplMotdStart = 375, // :- server Message of the Day RplMotd = 372, // :- RplMotdAlt = 377, // :- (some) RplMotdAlt2 = 378, // :- (some) RplMotdEnd = 376, // :End of /MOTD command. RplUModeIs = 221, // // IsOn/UserHost RplUserHost = 302, // :userhosts RplIsOn = 303, // :nicknames // Away RplAway = 301, // :away RplUnAway = 305, // :You are no longer marked as being away RplNowAway = 306, // :You have been marked as being away // WHOIS/WHOWAS RplWhoisHelper = 310, // :looks very helpful DALNET RplWhoIsUser = 311, // * : RplWhoIsServer = 312, // : RplWhoIsOperator = 313, // :is an IRC Operator RplWhoIsIdle = 317, // : RplEndOfWhois = 318, // :End of /WHOIS list. RplWhoIsChannels = 319, // : RplWhoWasUser = 314, // * : RplEndOfWhoWas = 369, // :End of WHOWAS RplWhoReply = 352, // : RplEndOfWho = 315, // :End of /WHO list. RplUserIPs = 307, // :userips UNDERNET RplUserIP = 340, // :=+@ UNDERNET // List RplListStart = 321, // Channel :Users Name RplList = 322, // : RplListEnd = 323, // :End of /LIST RplLinks = 364, // : RplEndOfLinks = 365, // :End of /LINKS list. // Post-Channel Join RplUniqOpIs = 325, RplChannelModeIs = 324, // RplChannelUrl = 328, // :url DALNET RplChannelCreated = 329, // RplNoTopic = 331, // :No topic is set. RplTopic = 332, // : RplTopicSetBy = 333, // RplNamReply = 353, // = : RplEndOfNames = 366, // :End of /NAMES list. // Invitational RplInviting = 341, // RplSummoning = 342, // Channel Lists RplInviteList = 346, // IRCNET RplEndOfInviteList = 357, // :End of Channel Invite List IRCNET RplExceptList = 348, // IRCNET RplEndOfExceptList = 349, // :End of Channel Exception List IRCNET RplBanList = 367, // RplEndOfBanList = 368, // :End of Channel Ban List // server/misc RplVersion = 351, // . : RplInfo = 371, // : RplEndOfInfo = 374, // :End of /INFO list. RplYoureOper = 381, // :You are now an IRC Operator RplRehashing = 382, // :Rehashing RplYoureService = 383, RplTime = 391, // : RplUsersStart = 392, RplUsers = 393, RplEndOfUsers = 394, RplNoUsers = 395, RplServList = 234, RplServListEnd = 235, RplAdminMe = 256, // :Administrative info about server RplAdminLoc1 = 257, // : RplAdminLoc2 = 258, // : RplAdminEMail = 259, // : RplTryAgain = 263, // :Server load is temporarily too heavy. Please wait a while and try again. // tracing RplTraceLink = 200, RplTraceConnecting = 201, RplTraceHandshake = 202, RplTraceUnknown = 203, RplTraceOperator = 204, RplTraceUser = 205, RplTraceServer = 206, RplTraceService = 207, RplTraceNewType = 208, RplTraceClass = 209, RplTraceReconnect = 210, RplTraceLog = 261, RplTraceEnd = 262, // stats RplStatsLinkInfo = 211, // : RplStatsCommands = 212, // RplStatsCLine = 213, // C * RplStatsNLine = 214, // N * RplStatsILine = 215, // I * RplStatsKLine = 216, // k * RplStatsPLine = 217, // P ?> ?> RplStatsQLine = 222, // : RplStatsELine = 223, // E * ?> ?> RplStatsDLine = 224, // D * ?> ?> RplStatsLLine = 241, // L * ?> ?> RplStatsuLine = 242, // :Server Up days, RplStatsoLine = 243, // o ?> RplStatsHLine = 244, // H * ?> ?> RplStatsGLine = 247, // G : RplStatsULine = 248, // U * ?> ?> ?> RplStatsZLine = 249, // :info RplStatsYLine = 218, // Y RplEndOfStats = 219, // :End of /STATS report RplStatsUptime = 242, // GLINE RplGLineList = 280, // UNDERNET RplEndOfGLineList = 281, // :End of G-line List UNDERNET // Silence RplSilenceList = 271, // UNDERNET/DALNET RplEndOfSilenceList = 272, // :End of Silence List UNDERNET/DALNET // LUser RplLUserClient = 251, // :There are users and invisible on servers RplLUserOp = 252, // :operator(s) online RplLUserUnknown = 253, // :unknown connection(s) RplLUserChannels = 254, // :channels formed RplLUserMe = 255, // :I have clients and servers RplLUserLocalUser = 265, // :Current local users: Max: RplLUserGlobalUser = 266, // :Current global users: Max: // Errors ErrNoSuchNick = 401, // :No such nick ErrNoSuchServer = 402, // :No such server ErrNoSuchChannel = 403, // :No such channel ErrCannotSendToChan = 404, // :Cannot send to channel ErrTooManyChannels = 405, // :You have joined too many channels ErrWasNoSuchNick = 406, // :There was no such nickname ErrTooManyTargets = 407, // :Duplicate recipients. No message delivered ErrNoColors = 408, // # :You cannot use colors on this channel. Not sent: DALNET ErrNoOrigin = 409, // :No origin specified ErrNoRecipient = 411, // :No recipient given ( ) ErrNoTextToSend = 412, // :No text to send ErrNoTopLevel = 413, // :No toplevel domain specified ErrWildTopLevel = 414, // :Wildcard in toplevel Domain ErrBadMask = 415, ErrTooMuchInfo = 416, // :Too many lines in the output, restrict your query UNDERNET ErrUnknownCommand = 421, // :Unknown command ErrNoMotd = 422, // :MOTD File is missing ErrNoAdminInfo = 423, // :No administrative info available ErrFileError = 424, ErrNoNicknameGiven = 431, // :No nickname given ErrErroneusNickname = 432, // :Erroneus Nickname ErrNickNameInUse = 433, // :Nickname is already in use. ErrNickCollision = 436, // :Nickname collision KILL ErrUnAvailResource = 437, // :Cannot change nickname while banned on channel ErrNickTooFast = 438, // :Nick change too fast. Please wait seconds. (most) ErrTargetTooFast = 439, // :Target change too fast. Please wait seconds. DALNET/UNDERNET ErrUserNotInChannel = 441, // :They aren't on that channel ErrNotOnChannel = 442, // :You're not on that channel ErrUserOnChannel = 443, // :is already on channel ErrNoLogin = 444, ErrSummonDisabled = 445, // :SUMMON has been disabled ErrUsersDisabled = 446, // :USERS has been disabled ErrNotRegistered = 451, // :Register first. ErrNeedMoreParams = 461, // :Not enough parameters ErrAlreadyRegistered= 462, // :You may not reregister ErrNoPermForHost = 463, ErrPasswdMistmatch = 464, ErrYoureBannedCreep = 465, ErrYouWillBeBanned = 466, ErrKeySet = 467, // :Channel key already set ErrServerCanChange = 468, // :Only servers can change that mode DALNET ErrChannelIsFull = 471, // :Cannot join channel (+l) ErrUnknownMode = 472, // :is unknown mode char to me ErrInviteOnlyChan = 473, // :Cannot join channel (+i) ErrBannedFromChan = 474, // :Cannot join channel (+b) ErrBadChannelKey = 475, // :Cannot join channel (+k) ErrBadChanMask = 476, ErrNickNotRegistered= 477, // :You need a registered nick to join that channel. DALNET ErrBanListFull = 478, // :Channel ban/ignore list is full ErrNoPrivileges = 481, // :Permission Denied- You're not an IRC operator ErrChanOPrivsNeeded = 482, // :You're not channel operator ErrCantKillServer = 483, // :You cant kill a server! ErrRestricted = 484, // :Cannot kill, kick or deop channel service UNDERNET ErrUniqOPrivsNeeded = 485, // :Cannot join channel (reason) ErrNoOperHost = 491, // :No O-lines for your host ErrUModeUnknownFlag = 501, // :Unknown MODE flag ErrUsersDontMatch = 502, // :Cant change mode for other users ErrSilenceListFull = 511 // :Your silence list is full UNDERNET/DALNET }; // eo enum Reply