⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ircmain.cpp

📁 eMule0.44b的原代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:

				//- These replies are used with the AWAY command (if
				//allowed).  RPL_AWAY is sent to any client sending a
				//PRIVMSG to a client which is away.  RPL_AWAY is only
				//sent by the server to which the client is connected.
				//Replies RPL_UNAWAY and RPL_NOWAWAY are sent when the
				//client removes and sets an AWAY message.		
				//301    RPL_AWAY
				//"<nick> :<away message>"
				//305    RPL_UNAWAY
				//":You are no longer marked as being away"
				//306    RPL_NOWAWAY
				//":You have been marked as being away"
				case 301:
				case 305:
				case 306:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Replies 311 - 313, 317 - 319 are all replies
                //generated in response to a WHOIS message.  Given that
				//there are enough parameters present, the answering
				//server MUST either formulate a reply out of the above
				//numerics (if the query nick is found) or return an
				//error reply.  The '*' in RPL_WHOISUSER is there as
				//the literal character and not as a wild card.  For
				//each reply set, only RPL_WHOISCHANNELS may appear
				//more than once (for long lists of channel names).
				//The '@' and '+' characters next to the channel name
				//indicate whether a client is a channel operator or
				//has been granted permission to speak on a moderated
				//channel.  The RPL_ENDOFWHOIS reply is used to mark
				//the end of processing a WHOIS message.
				//311    RPL_WHOISUSER
				//"<nick> <user> <host> * :<real name>"
				//312    RPL_WHOISSERVER
				//"<nick> <server> :<server info>"
				//313    RPL_WHOISOPERATOR
				//"<nick> :is an IRC operator"
				//317    RPL_WHOISIDLE
				//"<nick> <integer> :seconds idle"
				//318    RPL_ENDOFWHOIS
				//"<nick> :End of WHOIS list"
				//319    RPL_WHOISCHANNELS
				//"<nick> :*( ( "@" / "+" ) <channel> " " )"
				case 311:
				case 312:
				case 313:
				case 317:
				case 318:
				case 319:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- When replying to a WHOWAS message, a server MUST use
				//the replies RPL_WHOWASUSER, RPL_WHOISSERVER or
				//ERR_WASNOSUCHNICK for each nickname in the presented
				//list.  At the end of all reply batches, there MUST
				//be RPL_ENDOFWHOWAS (even if there was only one reply
				//and it was an error).
				//314    RPL_WHOWASUSER
				//"<nick> <user> <host> * :<real name>"
				//369    RPL_ENDOFWHOWAS
				//"<nick> :End of WHOWAS"
				case 314:
				case 369:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- Replies RPL_LIST, RPL_LISTEND mark the actual replies
				//with data and end of the server's response to a LIST
				//command.  If there are no channels available to return,
				//only the end reply MUST be sent.
				//321    RPL_LISTSTART
				//Obsolete. Not used.
                //322    RPL_LIST
				//"<channel> <# visible> :<topic>"
				//323    RPL_LISTEND
				//":End of LIST"
				case 321:
				{
					//Although it says this is obsolete, so far every server has sent it, so I use it.. :/
					m_pwndIRC->AddStatus( _T("Start of /LIST") );
					m_pwndIRC->m_serverChannelList.ResetServerChannelList();
					return;
				}
				case 322:
				{
					CString chanName, chanNum, chanDesc;
					int chanNumIndex, chanDescIndex;
					chanNumIndex = message.Find( _T(' ') );
					chanDescIndex = message.Find( _T(' '), chanNumIndex + 1);
					chanName = message.Left( chanNumIndex );
					chanNum = message.Mid( chanNumIndex + 1, chanDescIndex - chanNumIndex - 1 );
					if( chanDescIndex > 0 )
						chanDesc = message.Mid( chanDescIndex );
					else
						chanDesc = _T("");

					m_pwndIRC->m_serverChannelList.AddChannelToList( chanName, chanNum, chanDesc );
					return;
				}
				case 323:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- When sending a TOPIC message to determine the
				//channel topic, one of two replies is sent.  If
				//the topic is set, RPL_TOPIC is sent back else
				//RPL_NOTOPIC.
				//325    RPL_UNIQOPIS
				//"<channel> <nickname>"
				//324    RPL_CHANNELMODEIS
				//"<channel> <mode> <mode params>"
				//331    RPL_NOTOPIC
				//"<channel> :No topic is set"
				//332    RPL_TOPIC
				//"<channel> :<topic>"
				case 325:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				case 324:
				{
					//A mode was set..
					targetIndex = message.Find(_T(' '));
					if( targetIndex == -1 )
						throw CString( _T("SMIRC Error: Received Invalid Channel Mode (324).") );
					target = message.Mid(0, targetIndex);
					commandIndex = message.Find( _T(' '), targetIndex+1 );
					if( commandIndex == -1 )
						throw CString( _T("SMIRC Error: Received Invalid Channel Mode (324).") );
					command = message.Mid( targetIndex+1, commandIndex - targetIndex-1);
					command.Replace( _T("\004"), _T("%") );
					target2 = message.Mid( commandIndex + 1 );
					m_pwndIRC->ParseChangeMode( target, source, command, target2 );
					return;
				}
				case 331:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				case 332:
				{
					m_pwndIRC->AddStatus( message );
					target2Index = message.Find( _T(':') );
					if( target2Index == -1 )
						throw CString(_T("SMIRC Error: Received [322] with invalid new topic message"));
					target2 = message.Left( target2Index-1 );
					message = message.Mid( target2Index + 1);
					m_pwndIRC->SetTitle( target2, message );
					m_pwndIRC->AddInfoMessage( target2, _T("* Channel Title: %s"), message );
					return;
				}

				//- Returned by the server to indicate that the
				//attempted INVITE message was successful and is
				//being passed onto the end client.
				//341    RPL_INVITING
				//"<channel> <nick>"
				case 341:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- Returned by a server answering a SUMMON message to
				//indicate that it is summoning that user.
				//342    RPL_SUMMONING
				//"<user> :Summoning user to IRC"
				case 342:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- When listing the 'invitations masks' for a given channel,
				//a server is required to send the list back using the
				//RPL_INVITELIST and RPL_ENDOFINVITELIST messages.  A
				//separate RPL_INVITELIST is sent for each active mask.
				//After the masks have been listed (or if none present) a
				//RPL_ENDOFINVITELIST MUST be sent.
				//346    RPL_INVITELIST
				//"<channel> <invitemask>"
				//347    RPL_ENDOFINVITELIST
				//"<channel> :End of channel invite list
				case 346:
				case 347:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- When listing the 'exception masks' for a given channel,
				//a server is required to send the list back using the
				//RPL_EXCEPTLIST and RPL_ENDOFEXCEPTLIST messages.  A
				//separate RPL_EXCEPTLIST is sent for each active mask.
				//After the masks have been listed (or if none present)
				//a RPL_ENDOFEXCEPTLIST MUST be sent.
				//348    RPL_EXCEPTLIST
				//"<channel> <exceptionmask>"
				//349    RPL_ENDOFEXCEPTLIST
				//"<channel> :End of channel exception list"
				case 348:
				case 349:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- Reply by the server showing its version details.
				//The <version> is the version of the software being
				//used (including any patchlevel revisions) and the
				//<debuglevel> is used to indicate if the server is
				//running in "debug mode".
				//The "comments" field may contain any comments about
				//the version or further version details.
				//351    RPL_VERSION
				//"<version>.<debuglevel> <server> :<comments>"
				case 351:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- The RPL_WHOREPLY and RPL_ENDOFWHO pair are used
				//to answer a WHO message.  The RPL_WHOREPLY is only
				//sent if there is an appropriate match to the WHO
				//query.  If there is a list of parameters supplied
				//with a WHO message, a RPL_ENDOFWHO MUST be sent
				//after processing each list item with <name> being
				//the item.
				//352    RPL_WHOREPLY
				//"<channel> <user> <host> <server> <nick>
				//( "H" / "G" > ["*"] [ ( "@" / "+" ) ]
				//:<hopcount> <real name>"
				//315    RPL_ENDOFWHO
				//"<name> :End of WHO list"
				case 352:
				case 315:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- To reply to a NAMES message, a reply pair consisting
				//of RPL_NAMREPLY and RPL_ENDOFNAMES is sent by the
				//server back to the client.  If there is no channel
				//found as in the query, then only RPL_ENDOFNAMES is
				//returned.  The exception to this is when a NAMES
				//message is sent with no parameters and all visible
				//channels and contents are sent back in a series of
				//RPL_NAMEREPLY messages with a RPL_ENDOFNAMES to mark
				//the end.
				//353    RPL_NAMREPLY
				//"( "=" / "*" / "@" ) <channel>
				//:[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )
				//- "@" is used for secret channels, "*" for private
				//channels, and "=" for others (public channels).
				//366    RPL_ENDOFNAMES
				//"<channel> :End of NAMES list"
				case 353:
				{
					m_pwndIRC->m_nicklist.ShowWindow(SW_HIDE);;
					int getNickIndex1 = -1;
					CString getNickChannel;
					int getNickIndex = 1;
					CString getNick;
					int count = 0;

					getNickIndex1 = message.Find(_T(':'));
					if( getNickIndex1 < 4 )
						throw CString( _T("SMIRC Error: Received [353 command with misformated channel name list") );
					getNickChannel = message.Mid( 2, getNickIndex1 - 3 );

					m_pwndIRC->AddStatus( _T("") );
					m_pwndIRC->AddStatus( getNickChannel + _T(" ") + message.Mid( getNickIndex1 ));

					getNickIndex = message.Find( _T(' '), getNickIndex1);
					message.Replace( _T("\004"), _T("%") );
					while( getNickIndex > 0 )
					{
						count ++;
						getNick = message.Mid( getNickIndex1 + 1, getNickIndex - getNickIndex1 - 1);
						getNickIndex1 = getNickIndex;
						m_pwndIRC->m_nicklist.NewNick( getNickChannel, getNick );
						getNickIndex = message.Find( _T(' '), getNickIndex1 + 1 );
					}
					return;
				}
				case 366:
				{
					CString channel;
					channel = message.Mid(0, message.Find(_T(' ')));
					SendString(_T("MODE ")+channel);
					m_pwndIRC->m_nicklist.ShowWindow(SW_SHOW);
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- In replying to the LINKS message, a server MUST send
				//replies back using the RPL_LINKS numeric and mark the
				//end of the list using an RPL_ENDOFLINKS reply.
				//364    RPL_LINKS
				//"<mask> <server> :<hopcount> <server info>"
				//365    RPL_ENDOFLINKS
				//"<mask> :End of LINKS list"
				case 364:
				case 365:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- When listing the active 'bans' for a given channel,
				//a server is required to send the list back using the
				//RPL_BANLIST and RPL_ENDOFBANLIST messages.  A separate
				//RPL_BANLIST is sent for each active banmask.  After the
				//banmasks have been listed (or if none present) a
				//RPL_ENDOFBANLIST MUST be sent.
				//367    RPL_BANLIST
				//"<channel> <banmask>"
				//368    RPL_ENDOFBANLIST
				//"<channel> :End of channel ban list"
				case 367:
				case 368:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- A server responding to an INFO message is required to
				//send all its 'info' in a series of RPL_INFO messages
				//with a RPL_ENDOFINFO reply to indicate the end of the
				//replies.
				//371    RPL_INFO
				//":<string>"
				//374    RPL_ENDOFINFO
				//":End of INFO list"
				case 371:
				case 374:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- When responding to the MOTD message and the MOTD file
				//is found, the file is displayed line by line, with
				//each line no longer than 80 characters, using
				//RPL_MOTD format replies.  These MUST be surrounded
				//by a RPL_MOTDSTART (before the RPL_MOTDs) and an
				//RPL_ENDOFMOTD (after).
				//375    RPL_MOTDSTART
				//":- <server> Message of the day - "
				//372    RPL_MOTD
				//":- <text>"
				//376    RPL_ENDOFMOTD
				//":End of MOTD command"
				case 375:
				case 372:
				case 376:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

				//- RPL_YOUREOPER is sent back to a client which has
				//just successfully issued an OPER message and gained
				//operator status.
				//381    RPL_YOUREOPER
				//":You are now an IRC operator"
				case 381:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- If the REHASH option is used and an operator sends
				//a REHASH message, an RPL_REHASHING is sent back to
				//the operator.
				//382    RPL_REHASHING
				//"<config file> :Rehashing"
				case 382:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Sent by the server to a service upon successful
				//registration.
				//383    RPL_YOURESERVICE
				//"You are service <servicename>"
				case 383:
				{
					m_pwndIRC->AddStatus( message );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -