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

📄 ircmain.cpp

📁 eMule0.44b的原代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
				//- Generic error message used to report a failed file
				//operation during the processing of a message.
				//424    ERR_FILEERROR
				//":File error doing <file op> on <file>"
				case 424:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned when a nickname parameter expected for a
				//command and isn't found.
				//431    ERR_NONICKNAMEGIVEN
				//":No nickname given"
				case 431:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned after receiving a NICK message which contains
				//characters which do not fall in the defined set.  See
				//section 2.3.1 for details on valid nicknames.
				//432    ERR_ERRONEUSNICKNAME
				//"<nick> :Erroneous nickname"
				case 432:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned when a NICK message is processed that results
				//in an attempt to change to a currently existing
				//nickname.
				//433    ERR_NICKNAMEINUSE
				//"<nick> :Nickname is already in use"
				case 433:
				{
					if( !m_pwndIRC->GetLoggedIn() )
						Disconnect();
					m_pwndIRC->AddStatus( GetResString(IDS_IRC_NICKUSED));
					return;
				}

                //- Returned by a server to a client when it detects a
				//nickname collision (registered of a NICK that
				//already exists by another server).
				//436    ERR_NICKCOLLISION
				//"<nick> :Nickname collision KILL from <user>@<host>"
				case 436:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}

                //- Returned by a server to a user trying to join a channel
				//currently blocked by the channel delay mechanism.
				//- Returned by a server to a user trying to change nickname
				//when the desired nickname is blocked by the nick delay
				//mechanism.
				//437    ERR_UNAVAILRESOURCE
				//"<nick/channel> :Nick/channel is temporarily unavailable"
				case 437:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned by the server to indicate that the target
				//user of the command is not on the given channel.
				//441    ERR_USERNOTINCHANNEL
				//"<nick> <channel> :They aren't on that channel"
				case 441:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned by the server whenever a client tries to
				//perform a channel affecting command for which the
				//client isn't a member.
				//442    ERR_NOTONCHANNEL
				//"<channel> :You're not on that channel"
				case 442:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned when a client tries to invite a user to a
				//channel they are already on.
				//443    ERR_USERONCHANNEL
				//"<user> <channel> :is already on channel"
				case 443:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned by the summon after a SUMMON command for a
				//user was unable to be performed since they were not
				//logged in.
				//444    ERR_NOLOGIN
				//"<user> :User not logged in"
				case 444:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned as a response to the SUMMON command.  MUST be
				//returned by any server which doesn't implement it.
				//445    ERR_SUMMONDISABLED
				//":SUMMON has been disabled"
				case 445:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned as a response to the USERS command.  MUST be
				//returned by any server which does not implement it.
				//446    ERR_USERSDISABLED
				//":USERS has been disabled"
				case 446:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned by the server to indicate that the client
				//MUST be registered before the server will allow it
				//to be parsed in detail.
				//451    ERR_NOTREGISTERED
				//":You have not registered"
				case 451:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
                
				//- Returned by the server by numerous commands to
				//indicate to the client that it didn't supply enough
				//parameters.
				//461    ERR_NEEDMOREPARAMS
				//"<command> :Not enough parameters"
				case 461:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned by the server to any link which tries to
				//change part of the registered details (such as
				//password or user details from second USER message).
				//462    ERR_ALREADYREGISTRED
				//":Unauthorized command (already registered)"
				case 462:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned to a client which attempts to register with
				//a server which does not been setup to allow
				//connections from the host the attempted connection
				//is tried.
				//463    ERR_NOPERMFORHOST
				//":Your host isn't among the privileged"
				case 463:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned to indicate a failed attempt at registering
				//a connection for which a password was required and
				//was either not given or incorrect.
				//464    ERR_PASSWDMISMATCH
				//":Password incorrect"
				case 464:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned after an attempt to connect and register
				//yourself with a server which has been setup to
				//explicitly deny connections to you.
				//465    ERR_YOUREBANNEDCREEP
				//":You are banned from this server"
				case 465:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
                //- Sent by a server to a user to inform that access to the
				//server will soon be denied.
				//466    ERR_YOUWILLBEBANNED
				case 466:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Any command requiring operator privileges to operate
				//MUST return this error to indicate the attempt was
				//unsuccessful.
				//467    ERR_KEYSET
				//"<channel> :Channel key already set"
				//471    ERR_CHANNELISFULL"<channel> :Cannot join channel (+l)"
				//472    ERR_UNKNOWNMODE
				//"<char> :is unknown mode char to me for <channel>"
				//473    ERR_INVITEONLYCHAN
				//"<channel> :Cannot join channel (+i)"
				//474    ERR_BANNEDFROMCHAN
				//"<channel> :Cannot join channel (+b)"
				//475    ERR_BADCHANNELKEY
				//"<channel> :Cannot join channel (+k)"
				//476    ERR_BADCHANMASK
				//"<channel> :Bad Channel Mask"
				//477    ERR_NOCHANMODES
				//"<channel> :Channel doesn't support modes"
				//478    ERR_BANLISTFULL
				//"<channel> <char> :Channel list is full"
				//481    ERR_NOPRIVILEGES
				//":Permission Denied- You're not an IRC operator"
				case 467:
				case 471:
				case 472:
				case 473:
				case 474:
				case 475:
				case 476:
				case 477:
				case 478:
				case 481:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Any command requiring 'chanop' privileges (such as
				//MODE messages) MUST return this error if the client
				//making the attempt is not a chanop on the specified
				//channel.
				//482    ERR_CHANOPRIVSNEEDED
				//"<channel> :You're not channel operator"
				case 482:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Any attempts to use the KILL command on a server
				//are to be refused and this error returned directly
				//to the client.
				//483    ERR_CANTKILLSERVER
				//":You can't kill a server!"
				case 483:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Sent by the server to a user upon connection to indicate
				//the restricted nature of the connection (user mode "+r").
				//484    ERR_RESTRICTED
				//":Your connection is restricted!"
				case 484:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Any MODE requiring "channel creator" privileges MUST
				//return this error if the client making the attempt is not
				//a chanop on the specified channel.
				//485    ERR_UNIQOPPRIVSNEEDED
				//":You're not the original channel operator"
				case 485:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- If a client sends an OPER message and the server has
				//not been configured to allow connections from the
				//client's host as an operator, this error MUST be
				//returned.
				//491    ERR_NOOPERHOST
				//":No O-lines for your host"
				case 491:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Returned by the server to indicate that a MODE
				//message was sent with a nickname parameter and that
				//the a mode flag sent was not recognized.
				//501    ERR_UMODEUNKNOWNFLAG
				//":Unknown MODE flag"
				case 501:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
				
				//- Error sent to any user trying to view or change the
				//user mode for a user other than themselves.
				//502    ERR_USERSDONTMATCH
				//":Cannot change mode for other users"
				case 502:
				{
					m_pwndIRC->AddStatus( message );
					return;
				}
			}
		}
		m_pwndIRC->AddStatus( _T("[") + command + _T("]") + message );
	}
	catch(CString e )
	{
		m_pwndIRC->AddStatus(e);
	}
	catch(...)
	{
		if (thePrefs.GetVerbose())
			AddDebugLogLine(false, _T("Exception in CIrcMain::ParseMessage"));
	}
}

void CIrcMain::SendLogin()
{
	try
	{
		ircsocket->SendString(user);
		CString temp = _T("NICK ") + nick;
		ircsocket->SendString(temp);
	}
	catch(...)
	{
		if (thePrefs.GetVerbose())
			AddDebugLogLine(false, _T("Exception in CIrcMain::SendLogin"));
	}
}

void CIrcMain::ParsePerform()
{
	//We need to do the perform first and seperate from the help option.
	//This allows you to do all your passwords and stuff before joining the
	//help channel and to keep both options from interfering with each other.
	try
	{
		if (thePrefs.GetIrcUsePerform())
		{
			CString strUserPerform = thePrefs.GetIrcPerformString();
			strUserPerform.Trim();
			if (!strUserPerform.IsEmpty())
			{
				int iPos = 0;
				CString str = strUserPerform.Tokenize(_T("|"), iPos);
				str.Trim();
				while (!str.IsEmpty())
				{
					if (str.Left(1) == _T('/'))
						str = str.Mid(1);
					if (str.Left(3) == _T("msg"))
						str = _T("PRIVMSG") + str.Mid(3);
					if (str.Left(16).CompareNoCase(_T("PRIVMSG nickserv")) == 0)
						str = _T("ns") + str.Mid(16);
					if (str.Left(16).CompareNoCase(_T("PRIVMSG chanserv")) == 0)
						str = _T("cs") + str.Mid(16);
					ircsocket->SendString(str);
					str = strUserPerform.Tokenize(_T("|"), iPos);
					str.Trim();
				}
			}
		}
	}
	catch(...)
	{
		if (thePrefs.GetVerbose())
			AddDebugLogLine(false, _T("Exception in CIrcMain::ParsePerform(1)"));
	}

	try
	{
		if (thePrefs.GetIrcHelpChannel())
		{
			// NOTE: putting this IRC command string into the language resource file is not a good idea. most 
			// translators do not know that this resource string does NOT have to be translated.
	
			// Well, I meant to make this option a static perform string within the language so the default help could
			// be change to what ever channel by just changing the language.. I will just have to check these strings
			// before release.
			// This also allows the help string to do more then join one channel. It could add other features later.
			CString strJoinHelpChannel = GetResString(IDS_IRC_HELPCHANNELPERFORM);
			strJoinHelpChannel.Trim();
			if (!strJoinHelpChannel.IsEmpty())
			{
				int iPos = 0;
				CString str = strJoin

⌨️ 快捷键说明

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