#include <sstream>
#include "IRCClient.h"
-#include "md5.h"
+#include "MD5.h"
#include "cram_md5.h"
#include "trim.h"
#include "chomp.h"
#include "SplitJoin.h"
#include "base64.h"
+#include "config.h"
using std::string;
using std::stringstream;
bool IRCClient::_debug = true;
+// see rfc1459 for IRC-Protocoll Reference
+
IRCClient::IRCClient()
: _timeout(10*60*1000), _inRun(false)
{
IRCClient::Nick ( const string& nick )
{
_nick = nick;
- return Send ( "NICK " + _nick + "\n" );
+ Send ( "NICK " + _nick + "\n" );
+ PrivMsg ("NickServ", "IDENTIFY " + (string)PASS);
+ return true;
}
bool
bool
IRCClient::Join ( const string& channel )
{
- return Send ( "JOIN " + channel + "\n" );
+ return Send("JOIN " + channel + "\n");
}
bool
{
ThreadPool::Instance().Launch ( (ThreadPoolFunc*)IRCClient::Callback, this );
return 1;
- }
+ }
_inRun = true;
if ( _debug ) printf ( "IRCClient::Run() - waiting for responses\n" );
string buf;
}
else if ( cmd == "join" )
{
+ mychannel = text;
OnJoin ( src, text );
}
else if ( cmd == "part" )
{
OnNick ( src, text );
}
+ else if ( cmd == "kick" )
+ {
+ OnKick ();
+ }
else if ( isdigit(cmd[0]) )
{
int i = atoi(cmd.c_str());
switch ( i )
{
+
case 1: // "Welcome!" - i.e. it's okay to issue commands now...
OnConnected();
break;
+
case 353: // user list for channel....
{
p = text.c_str();
OnChannelUsers ( channel, users );
}
break;
+
case 366: // END of user list for channel
{
p = text.c_str();
OnEndChannelUsers ( channel );
}
break;
+
+ case 474: // You are banned
+ {
+ p = text.c_str();
+ p2 = strpbrk ( p, " :" );
+ if ( !p2 ) continue;
+ string channel ( p, p2-p );
+ OnBanned ( channel );
+ }
+ break;
+
+ case 433: // Nick in Use
+ {
+ string nick = _nick;
+ Nick (nick + "_");
+
+ PrivMsg ("NickServ", "GHOST " + nick + " " + PASS);
+
+ // HACK HACK HACK
+ Mode ( "+i" );
+ Join ( CHANNEL ); // this is because IRC client does not review if his commands were sucessfull
+
+ Sleep ( 1000 );
+ Nick ( nick );
+ }
+ break;
+
+ case 2: //MOTD
+ case 376: //MOTD
+ case 372:
+ break;
+
default:
if ( _debug ) printf ( "unknown command %i: %s", i, buf.c_str() );
break;