- some cleanup of the irc code
This commit is contained in:
parent
b178b1d1e9
commit
51ca2ccc91
|
@ -507,6 +507,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
if (ircClient != NULL && ircClient->isConnected() == true
|
if (ircClient != NULL && ircClient->isConnected() == true
|
||||||
&& ircClient->getHasJoinedChannel() == true) {
|
&& ircClient->getHasJoinedChannel() == true) {
|
||||||
ircClient->SendIRCCmdMessage(IRC_CHANNEL, "left the lobby");
|
ircClient->SendIRCCmdMessage(IRC_CHANNEL, "left the lobby");
|
||||||
|
sleep(30);
|
||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
|
@ -528,6 +529,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
if (ircClient != NULL && ircClient->isConnected() == true
|
if (ircClient != NULL && ircClient->isConnected() == true
|
||||||
&& ircClient->getHasJoinedChannel() == true) {
|
&& ircClient->getHasJoinedChannel() == true) {
|
||||||
ircClient->SendIRCCmdMessage(IRC_CHANNEL, "tries to create a game");
|
ircClient->SendIRCCmdMessage(IRC_CHANNEL, "tries to create a game");
|
||||||
|
sleep(30);
|
||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
@ -559,6 +561,7 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
if (ircClient != NULL && ircClient->isConnected() == true
|
if (ircClient != NULL && ircClient->isConnected() == true
|
||||||
&& ircClient->getHasJoinedChannel() == true) {
|
&& ircClient->getHasJoinedChannel() == true) {
|
||||||
ircClient->SendIRCCmdMessage(IRC_CHANNEL, "connecting to '"+serverLines[i]->getMasterServerInfo()->getServerTitle()+"'");
|
ircClient->SendIRCCmdMessage(IRC_CHANNEL, "connecting to '"+serverLines[i]->getMasterServerInfo()->getServerTitle()+"'");
|
||||||
|
sleep(30);
|
||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
@ -756,24 +759,26 @@ void MenuStateMasterserver::update() {
|
||||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient,string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));
|
||||||
if(ircClient != NULL) {
|
if(ircClient != NULL) {
|
||||||
std::vector<string> nickList = ircClient->getNickList();
|
std::vector<string> nickList = ircClient->getNickList();
|
||||||
|
|
||||||
|
if(currentIrcNick != ircClient->getNick()) {
|
||||||
|
currentIrcNick = ircClient->getNick();
|
||||||
|
consoleIRC.setStringToHighlight(currentIrcNick);
|
||||||
|
}
|
||||||
|
|
||||||
bool isNew=false;
|
bool isNew=false;
|
||||||
//check if there is something new
|
//check if there is something new
|
||||||
if( oldNickList.size()!=nickList.size()) {
|
if( oldNickList.size() != nickList.size()) {
|
||||||
isNew=true;
|
isNew=true;
|
||||||
if(currentIrcNick!=ircClient->getNick()){
|
|
||||||
currentIrcNick=ircClient->getNick();
|
|
||||||
consoleIRC.setStringToHighlight(currentIrcNick);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(int i = 0; i < nickList.size(); ++i) {
|
for(unsigned int i = 0; i < nickList.size(); ++i) {
|
||||||
if(nickList[i]!=oldNickList[i])
|
if(nickList[i] != oldNickList[i]) {
|
||||||
{
|
|
||||||
isNew=true;
|
isNew=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isNew) {
|
if(isNew) {
|
||||||
clearUserButtons();
|
clearUserButtons();
|
||||||
for(int i = 0; i < nickList.size(); ++i) {
|
for(int i = 0; i < nickList.size(); ++i) {
|
||||||
|
|
|
@ -52,7 +52,10 @@ public:
|
||||||
|
|
||||||
class IRCThread : public BaseThread
|
class IRCThread : public BaseThread
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
static bool debugEnabled;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::vector<string> argv;
|
std::vector<string> argv;
|
||||||
irc_session_t *ircSession;
|
irc_session_t *ircSession;
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,12 @@ using namespace Shared::PlatformCommon;
|
||||||
namespace Shared { namespace PlatformCommon {
|
namespace Shared { namespace PlatformCommon {
|
||||||
|
|
||||||
const int IRC_SERVER_PORT = 6667;
|
const int IRC_SERVER_PORT = 6667;
|
||||||
|
//bool IRCThread::debugEnabled = true;
|
||||||
|
bool IRCThread::debugEnabled = false;
|
||||||
|
|
||||||
void addlog (const char * fmt, ...) {
|
void addlog (const char * fmt, ...) {
|
||||||
//FILE * fp;
|
//FILE * fp;
|
||||||
char buf[1024];
|
char buf[8096];
|
||||||
va_list va_alist;
|
va_list va_alist;
|
||||||
|
|
||||||
va_start (va_alist, fmt);
|
va_start (va_alist, fmt);
|
||||||
|
@ -46,7 +48,7 @@ void addlog (const char * fmt, ...) {
|
||||||
#endif
|
#endif
|
||||||
va_end (va_alist);
|
va_end (va_alist);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: %s\n", buf);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: %s\n", buf);
|
||||||
|
|
||||||
//if(SystemFlags::VERBOSE_MODE_ENABLED == true) {
|
//if(SystemFlags::VERBOSE_MODE_ENABLED == true) {
|
||||||
// if ( (fp = fopen ("irctest.log", "ab")) != 0 ) {
|
// if ( (fp = fopen ("irctest.log", "ab")) != 0 ) {
|
||||||
|
@ -95,7 +97,7 @@ void event_notice (irc_session_t * session, const char * event, const char * ori
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("NOTICE from '%s': %s", origin, params[1]);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf("NOTICE from '%s': %s", origin, params[1]);
|
||||||
|
|
||||||
//if(strcasecmp (origin, "nickserv")) {
|
//if(strcasecmp (origin, "nickserv")) {
|
||||||
// return;
|
// return;
|
||||||
|
@ -119,7 +121,7 @@ void event_notice (irc_session_t * session, const char * event, const char * ori
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
else if(strstr (params[1], "Password accepted - you are now recognized") == params[1]) {
|
else if(strstr (params[1], "Password accepted - you are now recognized") == params[1]) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Nickserv authentication succeed.");
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf("Nickserv authentication succeed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +140,7 @@ void event_join(irc_session_t * session, const char * event, const char * origin
|
||||||
else {
|
else {
|
||||||
char realNick[128]="";
|
char realNick[128]="";
|
||||||
get_nickname(origin,realNick,127);
|
get_nickname(origin,realNick,127);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: user joined channel realNick [%s] origin [%s]\n", realNick,origin);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: user joined channel realNick [%s] origin [%s]\n", realNick,origin);
|
||||||
|
|
||||||
bool foundNick = false;
|
bool foundNick = false;
|
||||||
|
|
||||||
|
@ -146,7 +148,7 @@ void event_join(irc_session_t * session, const char * event, const char * origin
|
||||||
std::vector<string> nickList = ctx->getCachedNickList();
|
std::vector<string> nickList = ctx->getCachedNickList();
|
||||||
for(unsigned int i = 0;
|
for(unsigned int i = 0;
|
||||||
i < nickList.size(); ++i) {
|
i < nickList.size(); ++i) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: looking for match [%s] realNick [%s]\n", nickList[i].c_str(),realNick);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: looking for match [%s] realNick [%s]\n", nickList[i].c_str(),realNick);
|
||||||
|
|
||||||
if(nickList[i] == realNick) {
|
if(nickList[i] == realNick) {
|
||||||
foundNick = true;
|
foundNick = true;
|
||||||
|
@ -184,7 +186,7 @@ void event_connect (irc_session_t * session, const char * event, const char * or
|
||||||
void event_privmsg (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) {
|
void event_privmsg (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) {
|
||||||
dump_event (session, event, origin, params, count);
|
dump_event (session, event, origin, params, count);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("'%s' said me (%s): %s\n",origin ? origin : "someone",params[0], params[1] );
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("'%s' said me (%s): %s\n",origin ? origin : "someone",params[0], params[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcc_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length) {
|
void dcc_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length) {
|
||||||
|
@ -194,37 +196,37 @@ void dcc_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case LIBIRC_ERR_CLOSED:
|
case LIBIRC_ERR_CLOSED:
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("DCC %d: chat closed\n", id);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC %d: chat closed\n", id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
if ( !data ) {
|
if ( !data ) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("DCC %d: chat connected\n", id);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC %d: chat connected\n", id);
|
||||||
irc_dcc_msg (session, id, "Hehe");
|
irc_dcc_msg (session, id, "Hehe");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("DCC %d: %s\n", id, data);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC %d: %s\n", id, data);
|
||||||
sprintf (buf, "DCC [%d]: %d", id, count++);
|
sprintf (buf, "DCC [%d]: %d", id, count++);
|
||||||
irc_dcc_msg (session, id, buf);
|
irc_dcc_msg (session, id, buf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("DCC %d: error %s\n", id, irc_strerror(status));
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC %d: error %s\n", id, irc_strerror(status));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcc_file_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length) {
|
void dcc_file_recv_callback (irc_session_t * session, irc_dcc_t id, int status, void * ctx, const char * data, unsigned int length) {
|
||||||
if ( status == 0 && length == 0 ) {
|
if ( status == 0 && length == 0 ) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("File sent successfully\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("File sent successfully\n");
|
||||||
|
|
||||||
if ( ctx ) {
|
if ( ctx ) {
|
||||||
fclose ((FILE*) ctx);
|
fclose ((FILE*) ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( status ) {
|
else if ( status ) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("File sent error: %d\n", status);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("File sent error: %d\n", status);
|
||||||
|
|
||||||
if ( ctx ) {
|
if ( ctx ) {
|
||||||
fclose ((FILE*) ctx);
|
fclose ((FILE*) ctx);
|
||||||
|
@ -234,18 +236,18 @@ void dcc_file_recv_callback (irc_session_t * session, irc_dcc_t id, int status,
|
||||||
if ( ctx ) {
|
if ( ctx ) {
|
||||||
fwrite (data, 1, length, (FILE*) ctx);
|
fwrite (data, 1, length, (FILE*) ctx);
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("File sent progress: %d\n", length);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("File sent progress: %d\n", length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_channel(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) {
|
void event_channel(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) {
|
||||||
//IRC: Event "433", origin: "leguin.freenode.net", params: 3 [*|softcoder|Nickname is already in use.]
|
//IRC: Event "433", origin: "leguin.freenode.net", params: 3 [*|softcoder|Nickname is already in use.]
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf("In [%s::%s] Line: %d count = %d origin = %s\n",__FILE__,__FUNCTION__,__LINE__,count,(origin ? origin : "null"));
|
||||||
|
|
||||||
if ( count != 2 )
|
if ( count != 2 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: '%s' said in channel %s: %s\n",origin ? origin : "someone",params[0], params[1] );
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: '%s' said in channel %s: %s\n",origin ? origin : "someone",params[0], params[1] );
|
||||||
|
|
||||||
if ( !origin ) {
|
if ( !origin ) {
|
||||||
return;
|
return;
|
||||||
|
@ -253,7 +255,7 @@ void event_channel(irc_session_t * session, const char * event, const char * ori
|
||||||
|
|
||||||
char realNick[128]="";
|
char realNick[128]="";
|
||||||
get_nickname(origin,realNick,127);
|
get_nickname(origin,realNick,127);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: event signalled realNick [%s] origin [%s]\n", realNick,origin);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: event signalled realNick [%s] origin [%s]\n", realNick,origin);
|
||||||
|
|
||||||
IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||||
if(ctx != NULL) {
|
if(ctx != NULL) {
|
||||||
|
@ -281,13 +283,13 @@ void event_channel(irc_session_t * session, const char * event, const char * ori
|
||||||
if ( !strcmp (params[1], "dcc chat") ) {
|
if ( !strcmp (params[1], "dcc chat") ) {
|
||||||
irc_dcc_t dccid;
|
irc_dcc_t dccid;
|
||||||
irc_dcc_chat (session, 0, realNick, dcc_recv_callback, &dccid);
|
irc_dcc_chat (session, 0, realNick, dcc_recv_callback, &dccid);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("DCC chat ID: %d\n", dccid);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC chat ID: %d\n", dccid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !strcmp (params[1], "dcc send") ) {
|
if ( !strcmp (params[1], "dcc send") ) {
|
||||||
irc_dcc_t dccid;
|
irc_dcc_t dccid;
|
||||||
irc_dcc_sendfile (session, 0, realNick, "irctest.c", dcc_file_recv_callback, &dccid);
|
irc_dcc_sendfile (session, 0, realNick, "irctest.c", dcc_file_recv_callback, &dccid);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("DCC send ID: %d\n", dccid);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC send ID: %d\n", dccid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !strcmp (params[1], "topic") ) {
|
if ( !strcmp (params[1], "topic") ) {
|
||||||
|
@ -308,14 +310,14 @@ void event_channel(irc_session_t * session, const char * event, const char * ori
|
||||||
}
|
}
|
||||||
|
|
||||||
void irc_event_dcc_chat(irc_session_t * session, const char * nick, const char * addr, irc_dcc_t dccid) {
|
void irc_event_dcc_chat(irc_session_t * session, const char * nick, const char * addr, irc_dcc_t dccid) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("DCC chat [%d] requested from '%s' (%s)\n", dccid, nick, addr);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC chat [%d] requested from '%s' (%s)\n", dccid, nick, addr);
|
||||||
|
|
||||||
irc_dcc_accept (session, dccid, 0, dcc_recv_callback);
|
irc_dcc_accept (session, dccid, 0, dcc_recv_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void irc_event_dcc_send(irc_session_t * session, const char * nick, const char * addr, const char * filename, unsigned long size, irc_dcc_t dccid) {
|
void irc_event_dcc_send(irc_session_t * session, const char * nick, const char * addr, const char * filename, unsigned long size, irc_dcc_t dccid) {
|
||||||
FILE * fp;
|
FILE * fp;
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("DCC send [%d] requested from '%s' (%s): %s (%lu bytes)\n", dccid, nick, addr, filename, size);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("DCC send [%d] requested from '%s' (%s): %s (%lu bytes)\n", dccid, nick, addr, filename, size);
|
||||||
|
|
||||||
if ( (fp = fopen ("file", "wb")) == 0 ) {
|
if ( (fp = fopen ("file", "wb")) == 0 ) {
|
||||||
abort();
|
abort();
|
||||||
|
@ -329,11 +331,11 @@ void event_leave(irc_session_t *session, const char *event, const char *origin,
|
||||||
|
|
||||||
// someone left the channel.
|
// someone left the channel.
|
||||||
if(origin) {
|
if(origin) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: user left channel [%s]\n", origin);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: user left channel [%s]\n", origin);
|
||||||
|
|
||||||
char realNick[128]="";
|
char realNick[128]="";
|
||||||
get_nickname(origin,realNick,127);
|
get_nickname(origin,realNick,127);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: user left channel realNick [%s] origin [%s]\n", realNick,origin);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: user left channel realNick [%s] origin [%s]\n", realNick,origin);
|
||||||
|
|
||||||
IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
IRCThread *ctx = (IRCThread *)irc_get_ctx(session);
|
||||||
if(ctx != NULL) {
|
if(ctx != NULL) {
|
||||||
|
@ -341,7 +343,7 @@ void event_leave(irc_session_t *session, const char *event, const char *origin,
|
||||||
std::vector<string> &nickList = ctx->getCachedNickList();
|
std::vector<string> &nickList = ctx->getCachedNickList();
|
||||||
for(unsigned int i = 0;
|
for(unsigned int i = 0;
|
||||||
i < nickList.size(); ++i) {
|
i < nickList.size(); ++i) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: lookingfor match [%s] realNick [%s]\n", nickList[i].c_str(),realNick);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: lookingfor match [%s] realNick [%s]\n", nickList[i].c_str(),realNick);
|
||||||
|
|
||||||
if(nickList[i] == realNick) {
|
if(nickList[i] == realNick) {
|
||||||
nickList.erase(nickList.begin() + i);
|
nickList.erase(nickList.begin() + i);
|
||||||
|
@ -402,6 +404,9 @@ void event_numeric(irc_session_t * session, unsigned int event, const char * ori
|
||||||
case LIBIRC_RFC_RPL_NAMREPLY :
|
case LIBIRC_RFC_RPL_NAMREPLY :
|
||||||
{
|
{
|
||||||
if(event == LIBIRC_RFC_RPL_NAMREPLY) {
|
if(event == LIBIRC_RFC_RPL_NAMREPLY) {
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: LIBIRC_RFC_RPL_NAMREPLY count = %d\n", count);
|
||||||
|
|
||||||
std::vector<string> nickList;
|
std::vector<string> nickList;
|
||||||
if(count >= 4) {
|
if(count >= 4) {
|
||||||
for(unsigned int i = 3; i < count && params[i]; ++i) {
|
for(unsigned int i = 3; i < count && params[i]; ++i) {
|
||||||
|
@ -412,7 +417,7 @@ void event_numeric(irc_session_t * session, unsigned int event, const char * ori
|
||||||
|
|
||||||
char realNick[128]="";
|
char realNick[128]="";
|
||||||
get_nickname(tokens[j].c_str(),realNick,127);
|
get_nickname(tokens[j].c_str(),realNick,127);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: user joined channel realNick [%s] tokens[j] [%s]\n", realNick,tokens[j].c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: LIBIRC_RFC_RPL_NAMREPLY user joined channel realNick [%s] tokens[j] [%s]\n", realNick,tokens[j].c_str());
|
||||||
|
|
||||||
// Only show Megaglest users in the user list
|
// Only show Megaglest users in the user list
|
||||||
//if(strncmp(&realNick[0],"MG_",3) == 0) {
|
//if(strncmp(&realNick[0],"MG_",3) == 0) {
|
||||||
|
@ -454,11 +459,11 @@ IRCThread::IRCThread(const std::vector<string> &argv, IRCCallbackInterface *call
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCThread::signalQuit() {
|
void IRCThread::signalQuit() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: signalQuit [%p]\n",ircSession);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: signalQuit [%p]\n",ircSession);
|
||||||
|
|
||||||
if(ircSession != NULL) {
|
if(ircSession != NULL) {
|
||||||
setCallbackObj(NULL);
|
setCallbackObj(NULL);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: Quitting Channel\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: Quitting Channel\n");
|
||||||
irc_cmd_quit(ircSession, "MG Bot is closing!");
|
irc_cmd_quit(ircSession, "MG Bot is closing!");
|
||||||
BaseThread::signalQuit();
|
BaseThread::signalQuit();
|
||||||
hasJoinedChannel = false;
|
hasJoinedChannel = false;
|
||||||
|
@ -466,7 +471,7 @@ void IRCThread::signalQuit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRCThread::shutdownAndWait() {
|
bool IRCThread::shutdownAndWait() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC: shutdownAndWait [%p]\n",ircSession);
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC: shutdownAndWait [%p]\n",ircSession);
|
||||||
|
|
||||||
signalQuit();
|
signalQuit();
|
||||||
return BaseThread::shutdownAndWait();
|
return BaseThread::shutdownAndWait();
|
||||||
|
@ -549,7 +554,7 @@ void IRCThread::execute() {
|
||||||
ircSession=NULL;
|
ircSession=NULL;
|
||||||
|
|
||||||
if(argv.size() != 5) {
|
if(argv.size() != 5) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC Usage: <server> <nick> <channel> : got params [%ld]\n",(long int)argv.size());
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC Usage: <server> <nick> <channel> : got params [%ld]\n",(long int)argv.size());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +587,7 @@ void IRCThread::execute() {
|
||||||
ircSession = irc_create_session (&callbacks);
|
ircSession = irc_create_session (&callbacks);
|
||||||
|
|
||||||
if(!ircSession) {
|
if(!ircSession) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC Could not create session\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC Could not create session\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +613,7 @@ void IRCThread::execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->username.c_str(), "megaglest")) {
|
if(irc_connect(ircSession, argv[0].c_str(), IRC_SERVER_PORT, 0, this->nick.c_str(), this->username.c_str(), "megaglest")) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC Could not connect: %s\n", irc_strerror (irc_errno(ircSession)));
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC Could not connect: %s\n", irc_strerror (irc_errno(ircSession)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,11 +629,11 @@ void IRCThread::execute() {
|
||||||
this->getQuitStatus() == false && iAttempts <= 5;
|
this->getQuitStatus() == false && iAttempts <= 5;
|
||||||
++iAttempts) {
|
++iAttempts) {
|
||||||
if(irc_run(ircSession)) {
|
if(irc_run(ircSession)) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC Could not run the session: %s\n", irc_strerror (irc_errno(ircSession)));
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC Could not run the session: %s\n", irc_strerror (irc_errno(ircSession)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> IRC exiting IRC CLient!\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED || IRCThread::debugEnabled) printf ("===> IRC exiting IRC CLient!\n");
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
|
|
Loading…
Reference in New Issue