/* ==================== IRC_Callback_Numeric Libircclient event handler for numeric events. ==================== */ static void IRC_Callback_Numeric(void *session, unsigned int event, const char *origin, const char **params, unsigned int count) { unsigned int i; irc_session_t *s = (irc_session_t*)irc_get_ctx(session); if(irc_eventlog.integer) { IRC_Printf("^1%i^7 [^5%i^7] origin: %s, params: \n", ((irc_session_t*)irc_get_ctx(session))->handle, event, origin); for(i = 0; i < count; ++i) IRC_Printf(" %i: ^2%s\n", i, params[i]); } IRC_Callback_QuakeC(SVVM_prog, s->handle, NULL, event, origin, params, count); }
void event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session); dump_event (session, event, origin, params, count); irc_cmd_join (session, ctx->channel, 0); }
void event_numeric(irc_session_t *session,unsigned int event,const char *origin, const char **params, unsigned count) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); switch (event) { case LIBIRC_RFC_ERR_NICKNAMEINUSE: case LIBIRC_RFC_ERR_NICKCOLLISION: irc_auto_rename_nick(session); return; case LIBIRC_RFC_RPL_TOPIC: //topic notification on join if (count>2) { CslIrcEvent evt(context->Target,CslIrcEvent::TOPIC,A2U(params[1])); evt.Ints.Add(event); evt.AddCharData(params[2]); wxPostEvent(context->EvtHandler,evt); } return; case LIBIRC_RFC_RPL_NAMREPLY: if (count>3) { irc_notify_player_list(session,params[2],params[3]); return; } break; case LIBIRC_RFC_RPL_ENDOFNAMES: return; case LIBIRC_RFC_ERR_CANNOTSENDTOCHAN: if (count>2) { CslIrcEvent evt(context->Target,CslIrcEvent::NUMERIC,A2U(params[1])); evt.Ints.Add(event); evt.AddCharData(params[2]); wxPostEvent(context->EvtHandler,evt); return; } break; } wxUint32 i; wxString s,p; s<<event<<wxT(": "); for (i=0;i<count;i++) { p=A2U(params[i]); if (!p.CmpNoCase(context->Server->Network->Nick)) continue; s<<p<<wxT(" "); } CslIrcEvent evt(context->Target,CslIrcEvent::NUMERIC,s); evt.Ints.Add(event); wxPostEvent(context->EvtHandler,evt); }
void event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { sprintf(botnick,"%s",ctx.nick); irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session); irc_cmd_join (session, ctx->channel, 0); currentChannelCount++; }
void event_channel_notice(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { if (!origin || count != 2) return; struct ircbot_context * ctx = (struct ircbot_context *) irc_get_ctx(session); std::string message = params[1]; std::string user = origin; std::string command; printf("%s\n", message.c_str()); ctx->pLog->logMessage(&message); if (!ctx->pLog->mDatabase->existUser(&user)) ctx->pLog->mDatabase->createUser(&user); ctx->pLog->mDatabase->updateUser(&user); DEBUG("Message:" << message); DEBUG("User:"******"Command:" << command); ctx->pController->executeCommand(&command, ctx, &user); } }
/* ==================== IRC_Callback_Default Libircclient event handler for non-numeric events. ==================== */ static void IRC_Callback_Default(void *session, const char *event, const char *origin, const char **params, unsigned int count) { unsigned int i; irc_session_t *s = (irc_session_t*)irc_get_ctx(session); char nick[MAX_INPUTLINE]; if(irc_eventlog.integer) { IRC_Printf("^1%i^7 [^3%s^7] origin: %s, params: \n", s->handle, event, origin); for(i = 0; i < count; ++i) IRC_Printf(" %i: ^2%s\n", i, params[i]); } if(!strcmp(event, "CONNECT")) { // In case the server doesn't like our nickname strlcpy(s->nick, params[0], sizeof(s->nick)); } else if(!strcmp(event, "NICK")) { irc_target_get_nick(origin, nick, sizeof(nick)); if(!strcmp(s->nick, nick)) // our nickname changed strlcpy(s->nick, params[0], sizeof(s->nick)); } else if(!strcmp(event, "CTCP") && !strncmp(params[0], "VERSION", 7)) { char ctcpreply[sizeof(engineversion) + 8]; irc_target_get_nick(origin, nick, sizeof(nick)); strlcpy(ctcpreply, "VERSION ", sizeof(ctcpreply)); strlcat(ctcpreply, engineversion, sizeof(ctcpreply)); irc_cmd_ctcp_reply(s->session, nick, ctcpreply); } IRC_Callback_QuakeC(SVVM_prog, s->handle, event, -1, origin, params, count); }
void GaMatchmakingState::event_ctcp_action(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { GaMatchmakingState* pBridge = reinterpret_cast< GaMatchmakingState* >( irc_get_ctx( session ) ); BcScopedLock< BcMutex > Lock( pBridge->Lock_ ); }
void irc_eventcode_callback(irc_session_t *s, unsigned int event, const char *origin, const char **p, unsigned int count) { dazeus::Server *server = (dazeus::Server*) irc_get_ctx(s); std::vector<std::string> params; for(unsigned int i = 0; i < count; ++i) { params.push_back(std::string(p[i])); } server->slotNumericMessageReceived(std::string(origin), event, params); }
void event_join(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count) { irc_ctx_t *ctx = (irc_ctx_t*)irc_get_ctx(session); irc_thread_data *self = (irc_thread_data*)ctx->self; // shutup compiler complaining about unused variables (void) event; (void) origin; (void) params; (void) count; (void) self; }
void event_join( irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count ) { if ( !origin ) return; IRCSessionContext* p_ctx = static_cast< IRCSessionContext* >( irc_get_ctx( session ) ); p_ctx->_p_handler->joined( params[ 0 ], origin ); }
void Kommunikater::event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session); irc_cmd_join (session, ctx->channel, 0); thread_id_t tid; CREATE_THREAD(&tid, myThread, &state); }
void event_part( irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count ) { if ( !origin ) return; IRCSessionContext* p_ctx = static_cast< IRCSessionContext* >( irc_get_ctx( session ) ); p_ctx->_p_handler->left( params[ 0 ], std::string( origin ) ); }
/** * @brief Connect Event * Funktion wird aufgerufen, sobald der Bot sich mit dem Server erfolgreich verbunden hat. * @param session ein Pointer von irc_session_t, Session von der ein Event erzeugt wird. * @param event ein konstanter char Pointer, Event Name * @param origin ein konstanter char Pointer, Herkunfts Name * @param params const char, Liste der Parameter * @param count ein unsigned int, Anzahl der Parameter */ void event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session); irc_cmd_join (session, ctx->channel, 0); printf("Connected to Server!\n"); }
void event_kick( irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count ) { if ( !origin || ( count < 1 ) ) return; IRCSessionContext* p_ctx = static_cast< IRCSessionContext* >( irc_get_ctx( session ) ); p_ctx->_p_handler->recvKicked( params[ 0 ], std::string( origin ), std::string( params[ 1 ] ) ); }
void event_quit(irc_session_t *session,const char* WXUNUSED(event), const char *origin,const char **params,unsigned int count) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target,CslIrcEvent::QUIT,A2U(origin)); if (count>0) evt.AddCharData(params[0]); wxPostEvent(context->EvtHandler,evt); }
void GaMatchmakingState::event_nick(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { GaMatchmakingState* pBridge = reinterpret_cast< GaMatchmakingState* >( irc_get_ctx( session ) ); BcScopedLock< BcMutex > Lock( pBridge->Lock_ ); for( unsigned int i = 0; i < count; ++i ) { BcPrintf( "event_nick %s, %s\n", origin, params[i] ); } }
Twitch::~Twitch() { if ( session ) { TwitchContext *ctx = ( TwitchContext * ) irc_get_ctx( session ); if ( ctx ) { delete ctx; } Disconnect(); } }
void event_connect(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count) { irc_ctx_t *ctx = (irc_ctx_t*)irc_get_ctx(session); irc_thread_data *self = (irc_thread_data*)ctx->self; // shutup compiler complaining about unused variables (void) event; (void) origin; (void) params; (void) count; irc_debug(self, "(%s) connected to irc", ctx->nick); irc_cmd_join(session, ctx->channel, 0); }
void slack_handler_join( irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count) { irc_ctx_t *ctx = (irc_ctx_t *)irc_get_ctx(session); syslog(LOG_INFO, "%s connected to channel %s", origin, ctx->channel); }
void event_connect(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { struct ircbot_context * ctx = (struct ircbot_context *) irc_get_ctx(session); DEBUG("event connected") ctx->pConnection->mConnected = true; for (unsigned int i = 0; i < ctx->pConnection->mChannel.size(); i++) irc_cmd_join(session, ctx->pConnection->mChannel[i]->c_str(), 0); }
void GaMatchmakingState::event_privmsg(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { GaMatchmakingState* pBridge = reinterpret_cast< GaMatchmakingState* >( irc_get_ctx( session ) ); BcScopedLock< BcMutex > Lock( pBridge->Lock_ ); if ( pBridge->HandshakeState_ == HSS_WAIT_INVITE || pBridge->HandshakeState_ == HSS_WAIT_ADDR ) { // Grab short name from origin. static BcChar NameCopy[ 256 ]; BcStrCopy( NameCopy, origin ); BcChar* pNameEnd = BcStrStr( NameCopy, "!" ); if( pNameEnd != NULL ) { *pNameEnd = '\0'; } if(count > 1 && strstr( params[1], "ADDR:" ) == params[1] ) { BcPrintf( "Recv: %s\n", params[1] ); // We got send an address first, so send ours. if( ClientID_ == BcErrorCode ) { if( pBridge->sendLocalAddress( NameCopy ) ) { ClientID_ = 1; } else { // Failure :( pBridge->HandshakeState_ = HSS_WAIT_INVITE; return; } } BcU32 LA, LB, LC, LD, LE; BcU32 A, B, C, D, E; BcSScanf( params[1], "ADDR:%u.%u.%u.%u:%u/%u.%u.%u.%u:%u", &LA, &LB, &LC, &LD, &LE, &A, &B, &C, &D, &E ); pBridge->LANHandshakeAddr_ = LA << 24 | LB << 16 | LC << 8 | LD; pBridge->LANHandshakePort_ = LE; pBridge->RemoteHandshakeAddr_ = A << 24 | B << 16 | C << 8 | D; pBridge->RemoteHandshakePort_ = E; pBridge->HandshakeState_ = HSS_COMPLETE; } else { pBridge->HandshakeState_ = HSS_WAIT_INVITE; } } BcPrintf("event_privmsg done.\n"); }
void event_connect(irc_session_t *session,const char* WXUNUSED(event),const char *origin, const char** WXUNUSED(params),unsigned int WXUNUSED(count)) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); if (!context || !context->EvtHandler) return; CslIrcEvent evt(context->Target,CslIrcEvent::CONNECT); wxPostEvent(context->EvtHandler,evt); }
void event_privmsg(irc_session_t *session,const char* WXUNUSED(event), const char *origin,const char **params,unsigned int count) { if (count<2 || !*params[1]) return; CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target,CslIrcEvent::PRIVMSG,A2U(origin)); evt.AddCharData(params[1]); wxPostEvent(context->EvtHandler,evt); }
void event_numeric( irc_session_t * session, unsigned int event, const char * origin, const char ** params, unsigned int count ) { IRCSessionContext* p_ctx = static_cast< IRCSessionContext* >( irc_get_ctx( session ) ); // handle /names stuff if ( event == LIBIRC_RFC_RPL_NAMREPLY ) { std::vector< std::string > names; std::string namestring( params[ 3 ] ); yaf3d::explode( namestring, " ", &names ); // fill the list p_ctx->_p_handler->_nickNames.clear(); for ( size_t cnt = 0; cnt < names.size(); ++cnt ) p_ctx->_p_handler->_nickNames.push_back( names[ cnt ] ); } // this signalized the end of name list transmission else if ( event == LIBIRC_RFC_RPL_ENDOFNAMES ) { p_ctx->_p_handler->recvMemberList( params[ 1 ] ); } // handle /whois stuff else if ( event == LIBIRC_RFC_RPL_WHOISUSER ) { if ( count > 1 ) { std::string header( "WHOIS " ); header += params[ 1 ]; p_ctx->_p_handler->recvMessage( p_ctx->_channel, "* ", header ); for ( unsigned int cnt = 2; cnt < count; cnt ++ ) p_ctx->_p_handler->recvMessage( p_ctx->_channel, "- ", params[ cnt ] ); } } else if ( event == LIBIRC_RFC_RPL_ENDOFWHOIS ) { p_ctx->_p_handler->recvMessage( p_ctx->_channel, "* ", "--------" ); } // just output system message else if ( event > 400 ) { std::string msg; if ( count > 0 ) msg += std::string( params[ 0 ] ); if ( count > 1 ) msg += " " + std::string( params[ 1 ] ); if ( count > 2 ) msg += " " + std::string( params[ 2 ] ); p_ctx->_p_handler->recvSystemMessage( msg ); } }
void slack_handler_connect( irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count) { syslog(LOG_INFO, "Connecting To IRC Server"); irc_ctx_t *ctx = (irc_ctx_t *)irc_get_ctx(session); irc_cmd_join(session, ctx->channel, NULL); //TODO: Add password handling from ctx object }
void event_ctcp_action(irc_session_t *session,const char* WXUNUSED(event),const char *origin, const char **params,unsigned int count) { if (count<2) return; CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target,CslIrcEvent::ACTION,A2U(params[0])); evt.AddCharData(origin); evt.AddCharData(params[1]); wxPostEvent(context->EvtHandler,evt); }
void GaMatchmakingState::event_numeric(irc_session_t * session, unsigned int event, const char * origin, const char ** params, unsigned int count) { GaMatchmakingState* pBridge = reinterpret_cast< GaMatchmakingState* >( irc_get_ctx( session ) ); BcScopedLock< BcMutex > Lock( pBridge->Lock_ ); if( event == LIBIRC_RFC_RPL_NAMREPLY ) { for( unsigned int i = 0; i < count; ++i ) { BcPrintf( "event_numeric LIBIRC_RFC_RPL_NAMREPLY: %s, %s\n", origin, params[i] ); } } }
void event_join(irc_session_t *session,const char* WXUNUSED(event),const char *origin, const char **params,unsigned int WXUNUSED(count)) { CslIrcContext *context=(CslIrcContext*)irc_get_ctx(session); CslIrcEvent evt(context->Target); evt.Channel=A2U(params[0]); evt.Strings.Add(A2U(origin)); evt.Type=context->Server->Network->Nick==A2U(origin) ? CslIrcEvent::JOIN : CslIrcEvent::JOINED; wxPostEvent(context->EvtHandler,evt); }
void GaMatchmakingState::event_connect(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { GaMatchmakingState* pBridge = reinterpret_cast< GaMatchmakingState* >( irc_get_ctx( session ) ); BcScopedLock< BcMutex > Lock( pBridge->Lock_ ); for( unsigned int i = 0; i < count; ++i ) { BcPrintf( "event_connect %s, %s\n", origin, params[i] ); } // Join the channel. irc_cmd_join( session, pBridge->Channel_, NULL ); }
void event_part (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { char nickbuf[128]; irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session); irc_target_get_nick (origin, nickbuf, sizeof(nickbuf)); if ( ctx->userLogged.find(nickbuf) != ctx->userLogged.end() ) { ctx->userLogged.erase (nickbuf); } }