void event_channel (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { printf ("'%s' said in channel %s: %s\n", origin ? origin : "someone", params[0], params[1] ); char * stripped = irc_color_strip_from_mirc (params[1]); irc_cmd_msg (session, params[0], stripped); free (stripped); stripped = irc_color_convert_from_mirc (params[1]); irc_cmd_msg (session, params[0], stripped); free (stripped); if ( !strcmp (params[1], "test") ) { char * str = irc_color_convert_to_mirc ("normal, [B]bold[/B], [I]reverse[/I], [U]underline[/U], [COLOR=RED]red on white[/COLOR], [COLOR=YELLOW/BLACK]yellow on black[/COLOR]"); irc_cmd_msg (session, params[0], str); free (str); } if ( strstr (params[1], "testme") == params[1] ) { char * str = irc_color_convert_to_mirc (params[1] + 7); irc_cmd_msg (session, params[0], str); free (str); } }
void voting_init(irc_session_t* session, const char* send_to, char* motive) { vote_cursor = 0; voters_cursor = 0; if (vote_open) { voting_close(session, send_to); } strcpy(reason, motive); vote_open = true; #ifdef VOTE_TIMEOUT alarm_session = session; strcpy(alarm_send_to, send_to); #endif irc_cmd_msg(session, send_to, "Opened voting for:"); irc_cmd_msg(session, send_to, reason); #ifdef VOTE_TIMEOUT signal(SIGALRM, voting_timeout); alarm(120); #endif }
void cmd_help(irc_session_t* session, const char* cmd, const char* origin, char* args) { int cmd_nb = get_cmd_nb(); int i; if(args[0] == '\0') { int out_len = 1 + 12 /* "Commandes : " */; char* out_str; for(i=0; i<cmd_nb; i++) out_len += strlen(cmds[i].cmd_str) + 1 /* ' ' */; out_str = malloc(out_len * sizeof(char)); out_str[0] = '\0'; for(i=0; i<cmd_nb; i++) { strcat(out_str, cmds[i].cmd_str); strcat(out_str, " "); } irc_cmd_msg(session, channel, out_str); log_and_print_said(botnick, out_str); free(out_str); } else { for(i=0; i<cmd_nb; i++) { if(strcmp(cmds[i].cmd_str, &args[1]) == 0) { irc_cmd_msg(session, channel, cmds[i].cmd_description); log_and_print_said(botnick, cmds[i].cmd_description); } } } }
void event_join( irc_session_t *irc_session, const char *event, const char *origin, const char **params, unsigned int count ) { ConfigArrayPtr settings[2]; char nickbuf[128]; char buffer[512]; dump_event( irc_session, event, origin, params, count ); irc_cmd_user_mode( irc_session, "+i" ); irc_target_get_nick( origin, nickbuf, sizeof(nickbuf) ); settings[0] = GetSetting( "IRC Bot Nick" ); if( !strcmp( nickbuf, settings[0]->string_value ) ) { info( "IRC Bot Joined Channel: %s", params[0] ); snprintf(buffer, sizeof(buffer), "op %s", params[0] ); irc_cmd_msg( irc_session, "ChanServ", buffer ); } else if( !strcmp( nickbuf, "ChanServ" ) ) { settings[0] = GetSetting( "IRC Bot Pass" ); if( settings[0]->string_value ){ snprintf(buffer, sizeof(buffer), "identify %s", settings[0]->string_value ); irc_cmd_msg( irc_session, "NickServ", buffer); } snprintf(buffer, sizeof(buffer), "op %s", params[0] ); irc_cmd_msg( irc_session, "ChanServ", buffer ); } return; }
void cmd_quit(irc_session_t* session, const char* cmd, const char* origin, char* args) { if(!strcmp(origin, master_origin)) { if(args[0] == '\0') { irc_cmd_msg(session, channel, "bien sûr, Maître !"); irc_cmd_quit(session, NULL); } } else { char nick[20]; irc_target_get_nick(origin, nick, 20); char msg[100]; sprintf(msg, "%s: bien essayé :>", nick); irc_cmd_msg(session, channel, msg); } }
void event_channel (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { char nickbuf[128]; if ( count != 2 ) return; printf ("'%s' said in channel %s: %s\n", origin ? origin : "someone", params[0], params[1] ); if ( !origin ) return; irc_target_get_nick (origin, nickbuf, sizeof(nickbuf)); if ( !strcmp (params[1], "quit") ) irc_cmd_quit (session, "of course, Master!"); if ( !strcmp (params[1], "help") ) { irc_cmd_msg (session, params[0], "quit, help, dcc chat, dcc send, ctcp"); } if ( !strcmp (params[1], "ctcp") ) { irc_cmd_ctcp_request (session, nickbuf, "PING 223"); irc_cmd_ctcp_request (session, nickbuf, "FINGER"); irc_cmd_ctcp_request (session, nickbuf, "VERSION"); irc_cmd_ctcp_request (session, nickbuf, "TIME"); } if ( !strcmp (params[1], "dcc chat") ) { irc_dcc_t dccid; irc_dcc_chat (session, 0, nickbuf, dcc_recv_callback, &dccid); printf ("DCC chat ID: %d\n", dccid); } if ( !strcmp (params[1], "dcc send") ) { irc_dcc_t dccid; irc_dcc_sendfile (session, 0, nickbuf, "irctest.c", dcc_file_recv_callback, &dccid); printf ("DCC send ID: %d\n", dccid); } if ( !strcmp (params[1], "topic") ) irc_cmd_topic (session, params[0], 0); else if ( strstr (params[1], "topic ") == params[1] ) irc_cmd_topic (session, params[0], params[1] + 6); if ( strstr (params[1], "mode ") == params[1] ) irc_cmd_channel_mode (session, params[0], params[1] + 5); if ( strstr (params[1], "nick ") == params[1] ) irc_cmd_nick (session, params[1] + 5); if ( strstr (params[1], "whois ") == params[1] ) irc_cmd_whois (session, params[1] + 5); }
static void send(module_t *module, const char *channel, const char *message) { irc_t *irc = (irc_t *)module; if (strncmp(message, me_prefix, strlen(me_prefix)) == 0) { const char *action = message + strlen(me_prefix); // Transmit an action printf("[%s] * %s %s\n", channel, irc->current_nick, action); if (irc_cmd_me(irc->session, channel, action)) { fprintf(stderr, "irc: %s\n", irc_strerror(irc_errno(irc->session))); return; } } else { // Send a regular message printf("[%s] <%s> %s\n", channel, irc->current_nick, message); if (irc_cmd_msg(irc->session, channel, message)) { fprintf(stderr, "irc: %s\n", irc_strerror(irc_errno(irc->session))); return; } } bot_on_read_log(module->bot, irc->current_nick, message); }
void IrcClient::OnConnect(irc_session_t* session , const char* event , const char* origin , const char** params , unsigned int count ) { String host = origin ; String message = params[1] ; bool is_bitlbee = message.startsWith(IRC::BITLBEE_WELCOME_MSG) ; String channel = STRING(NetworkStore[CONFIG::CHANNEL_ID]) ; DEBUG_TRACE_CONNECTED // set actual connected host for this network AvCaster::SetValue(CONFIG::HOST_ID , host) ; // display connected message AddClientChat(IRC::LOGGED_IN_MSG + host) ; AddServerChat(message) ; if (is_bitlbee) { // identify with bitlbee String identify_cmd = IRC::BITLBEE_IDENTIFY_CMD + "this->pass" ; irc_cmd_msg(session , IRC::BITLBEE_ROOT_CHANNEL , CHARSTAR(identify_cmd)) ; //irc_cmd_join(session , IRC::BITLBEE_XMPP_CHANNEL , NULL) ; // FIXME: when to join? } else irc_cmd_join(session , CHARSTAR(channel) , NULL) ; // reset retries counter SetRetries(IRC::MAX_N_RETRIES) ; }
void IRC::processAutoResponse(ircMsg& ircMsg) { std::cout << "IRC::processAutoResponse(): " << ircMsg.bridge.ircChannelName << std::endl; std::vector<std::string> ans; // get name for channel // no need for find() - if the session doesn't exist things are really bad ... std::string ownNick = _sessionServerMap[ircMsg.session].nickName; if(_cb->_ar->processMsgIrc(ircMsg.msg, ircMsg.nick, ans, ownNick)) //chat nick is needed for replacement { std::cout << " -- answers: " << ans.size() << std::endl; std::vector<std::string>::iterator it; for(it = ans.begin(); it != ans.end(); it++) { std::string msg = *it; std::cout << " -- " << msg << std::endl; std::vector<std::string> parts = split(*it, AutoResponse::IRC_NEW_LINE_MARKER); for(uint8_t i = 0; i < parts.size(); i++) { std::cout << " -- splitted into: " << parts[i]; irc_cmd_msg(ircMsg.session, ircMsg.bridge.ircChannelName.c_str(), parts[i].c_str()); } } } }
void IRC::processMsg(ircMsg& ircMsg) { // send to RS if(_cb->_rpc != NULL) { std::string message = "<" + ircMsg.nick + "> " + ircMsg.msg; _cb->_rpc->ircToRS(ircMsg.bridge.rsLobbyName, message); if(ircMsg.msg == "!list") { std::vector<std::string> nameList = _cb->_rpc->getRsLobbyParticipant(ircMsg.bridge.rsLobbyName); // build answer const std::string seperator = ", "; std::string answer = ""; answer += "People on RS side:"; std::vector<std::string>::iterator it; for(it = nameList.begin(); it != nameList.end(); it++) answer += (*it) + seperator; answer.substr(0, answer.length() - seperator.length() - 1); irc_cmd_msg(ircMsg.session, ircMsg.bridge.ircChannelName.c_str(), answer.c_str()); } } }
void voting_close(irc_session_t* session, const char* send_to) { #ifdef VOTE_TIMEOUT signal(SIGALRM, SIG_IGN); #endif irc_cmd_msg(session, send_to, "Closed voting for:"); voting_report(session, send_to); vote_open = false; }
void dazeus::Server::message( const std::string &destination, const std::string &message ) { std::stringstream ss(message); std::string line; while(std::getline(ss, line)) { ircEventMe("PRIVMSG_ME", destination, message); irc_cmd_msg(IRC, destination.c_str(), line.c_str()); } }
void event_channel (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); if ( !origin || count != 2 ) return; if ( strstr (params[1], "f**k") == 0 ) return; char nickbuf[128], text[256]; irc_target_get_nick (origin, nickbuf, sizeof(nickbuf)); if ( ctx->insolents.find(nickbuf) == ctx->insolents.end() ) ctx->insolents[nickbuf] = 0; ctx->insolents[nickbuf]++; printf ("'%s' swears in the channel '%s' %d times\n", nickbuf, params[1], ctx->insolents[nickbuf]); switch (ctx->insolents[nickbuf]) { case 1: // Send a private message sprintf (text, "%s, please do not swear in this channel.", nickbuf); irc_cmd_msg (session, nickbuf, text); break; case 2: // Send a channel message sprintf (text, "%s, do not swear in this channel, or you'll leave it.", nickbuf); irc_cmd_msg (session, params[0], text); break; default: // Send a channel notice, and kick the insolent sprintf (text, "kicked %s from %s for swearing.", nickbuf, params[0]); irc_cmd_me (session, params[0], text); irc_cmd_kick (session, nickbuf, params[0], "swearing"); break; } }
void botcmd_randkick(irc_session_t* session) { int n; char* to_kick; n = random() % name_count; if (name_list[n][0] != '+' && name_list[n][0] != '@') { to_kick = &name_list[n][0]; } else { to_kick = &name_list[n][1]; } irc_cmd_msg(session, bot_channel, "Random kick to: "); irc_cmd_msg(session, bot_channel, to_kick); irc_cmd_kick(session, to_kick, bot_channel,"Random kick"); }
void Twitch::SendChatMessage( const std::string &message ) { if ( !session ) { return; } if ( irc_cmd_msg( session, channel.c_str(), message.c_str() ) ) { OnError( irc_errno( session ), irc_strerror( irc_errno( session ) ) ); } }
void botcmd_goatsex(irc_session_t* session, const char* send_to) { int n; n = random() % 3; switch (n) { case 0: irc_cmd_msg(session, send_to, "http://tinyurl.com/yzchvdx"); break; case 1: irc_cmd_msg(session, send_to, "http://tinyurl.com/349etw"); break; case 2: irc_cmd_msg(session, send_to, "http://tinyurl.com/ygxmkwb"); break; } }
void add_manual (const char *ircline) { FILE *manual_file; char manual_line[1024] = ""; char machine[12] = ""; char url[1024] = ""; char *token; strcpy (manual_line, ircline); token = strtok (manual_line, " "); token = strtok (NULL, " "); if (token != NULL) strcpy (machine, token); token = strtok (NULL, " "); if (token != NULL) strcpy (url, token); if ((strlen (url) < 1) || (strlen (machine) < 1)) { fprintf (stderr, "Error adding manual, %s %s\n", machine, url); irc_cmd_msg (session, irc_cfg.channel, "Whoops, did you forget something? !add_manual machine url"); return; } manual_file = fopen (DEFAULT_MANUAL_FILE, "a"); if (manual_file == NULL) { fprintf (stderr, "Error opening %s for appending\n", DEFAULT_MANUAL_FILE); return; } strcpy (manual_line, machine); strcat (manual_line, "|"); strcat (manual_line, url); if (verbose) fprintf (stdout, "Adding manual: %s\n", manual_line); fputs (manual_line, manual_file); fputc ('\n', manual_file); fclose (manual_file); strcpy (manual_line, "Adding manual URL for machine "); strcat (manual_line, machine); irc_cmd_msg (session, irc_cfg.channel, manual_line); }
void Kommunikater::sendMassageLOG(irc_session_t * session) { irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session); std::vector<eintrag> e = Doc->readDB(); for (std::vector<eintrag>::iterator it = e.begin(); it!=e.end(); ++it) { printf("%s\n", it->name.c_str()); printf("%s\n", it->inhalt.c_str()); printf("%s\n", it->date.c_str()); printf("%s\n", it->time.c_str()); irc_cmd_msg(session, ctx->channel, it->name.c_str()); irc_cmd_msg(session, ctx->channel, it->inhalt.c_str()); irc_cmd_msg(session, ctx->channel, it->date.c_str()); irc_cmd_msg(session, ctx->channel, it->time.c_str()); } }
void cmd_say(irc_session_t* session, const char* cmd, const char* origin, char* args) { if(args[0] != '\0') { char* what_to_say = &args[1]; /* l'espace après 'say' */ irc_cmd_msg(session, channel, what_to_say); char nick[20]; irc_target_get_nick(origin, nick, 20); log_and_print("%s m'a dit de dire : %s", nick, what_to_say); log_and_print_said(botnick, what_to_say); } }
bool CslIrcSession::SendTextMessage(const wxString& channel,const wxString& text) { if (m_state!=STATE_CONNECTED) return false; wxCharBuffer buffer; if (ConvertToChannelEncoding(channel,text,buffer)) return irc_cmd_msg(m_context.Session,U2A(channel),buffer)==0; return false; }
//////////////////////////////////////////////////////////////////////////////// // bridge BcBool GaMatchmakingState::sendLocalAddress( const BcChar* pDest ) { BcBool GotPort = BcTrue; if( MappedHandshakeAddr_ == 0 ) { doSTUN(); } if( GotPort ) { // Got a port open, also grab our LAN address. struct in_addr Addr; BcMemZero( &Addr, sizeof( Addr ) ); char HostName[ 128 ]; if( gethostname( HostName, sizeof( HostName ) ) != SOCKET_ERROR ) { struct hostent* pHostEntry = gethostbyname( HostName ); if( pHostEntry != NULL ) { for( int Idx = 0; pHostEntry->h_addr_list[ Idx ] != 0; ++Idx ) { memcpy( &Addr, pHostEntry->h_addr_list[ Idx ], sizeof( struct in_addr ) ); break; } } } // BcChar AddrBuffer[ 256 ]; BcSPrintf( AddrBuffer, "ADDR:%u.%u.%u.%u:%u/%u.%u.%u.%u:%u", Addr.S_un.S_un_b.s_b1, Addr.S_un.S_un_b.s_b2, Addr.S_un.S_un_b.s_b3, Addr.S_un.S_un_b.s_b4, LocalHandshakePort_, ( MappedAddress_.addr >> 24 ) & 0xff, ( MappedAddress_.addr >> 16 ) & 0xff, ( MappedAddress_.addr >> 8 ) & 0xff, ( MappedAddress_.addr ) & 0xff, MappedAddress_.port ); BcPrintf( "Send: %s (%u)\n", AddrBuffer, LocalHandshakePort_ ); // Send message. BcPrintf( "pre-irc_cmd_msg:\n" ); int RetVal = irc_cmd_msg( pSession_, pDest, AddrBuffer ); BcPrintf( "irc_cmd_msg: %u\n", RetVal ); } return GotPort; }
void voting_report(irc_session_t* session, const char* send_to) { char buf[256]; int i; if (!vote_open) { if (vote_cursor == -1) { irc_cmd_notice(session, send_to, "There's no open voting"); return; } else { irc_cmd_notice(session, send_to, "The voting is closed"); } } irc_cmd_msg(session, send_to, reason); for (i = 0; i < vote_cursor; i++) { sprintf(buf, "%d - <%s> %d votes", i + 1, vote_opts[i], vote_count[i]); irc_cmd_msg(session, send_to, buf); } }
void IRC::rsToIrc(std::string& lobbyName, std::string& message) { std::cout << "IRC::rsToIrc() lobby: " << lobbyName << " msg: " << message << std::endl; // search server/channel irc_session_t* session = NULL; ConfigHandler::IRCOptions_Server s; ConfigHandler::IRCOptions_Bridge b; bool found = rsLobbyNameToIrc(lobbyName, session, s, b); if(found) irc_cmd_msg(session, b.ircChannelName.c_str(), message.c_str()); else std::cerr << "IRC::rsToIrc() unable to find a fitting IRC channel (rs lobby: " << lobbyName << ")" << std::endl; }
void event_connect( irc_session_t *irc_session, const char *event, const char *origin, const char **params, unsigned int count ) { ConfigArrayPtr setting; char buffer[512]; dump_event (irc_session, event, origin, params, count); info( "IRC Bot Connected to server: %s", origin ); setting = GetSetting( "IRC Bot Pass" ); if( setting->string_value ){ snprintf(buffer, sizeof(buffer), "identify %s", setting->string_value ); irc_cmd_msg(sysconfig.irc_session, "NickServ", buffer); } setting = GetSetting( "IRC Channel" ); irc_cmd_join( irc_session, setting->string_value, 0 ); return; }
void find_manual (const char *manual) { FILE *manual_file; char lineread[1024] = ""; char *reply; int found_manual = 0; manual_file = fopen (DEFAULT_MANUAL_FILE, "r"); if (manual_file == NULL) { fprintf (stderr, "Error opening %s for reading\n", DEFAULT_MANUAL_FILE); return; } //Read throught the manual file line by line while (fgets (lineread, 1024, manual_file) != NULL) { if (strncasecmp (lineread, manual, strlen(manual)) == 0) { found_manual = 1; strtok (lineread, "|"); reply = strtok (NULL, "|"); irc_cmd_msg (session, irc_cfg.channel, reply); } } fclose (manual_file); if (found_manual == 0) { strcpy (lineread, "Couldn't find a manual for "); strcat (lineread, manual); irc_cmd_msg (session, irc_cfg.channel, lineread); } }
void check_manual (const char *ircline) { //Manual to look for char manual[12] = ""; //No machine specified if (strlen (ircline) <= strlen (MAGIC_MANUAL)) { irc_cmd_msg (session, irc_cfg.channel, "What manual do you want me to look for?"); return; } strcpy (manual, ircline + (strlen (MAGIC_MANUAL) + 1)); if (verbose) fprintf (stdout, "Looking for manual %s\n", manual); find_manual (manual); }
static int lua_irc_cmd_msg(lua_State *L) { void *session; const char *nch,*msg; int result=LIBIRC_ERR_INVAL; if(lua_gettop(L)==3){ session=lua_touserdata(L,1); if(session!=NULL){ nch=lua_tostring(L,2); msg=lua_tostring(L,3); if((nch!=NULL) && (msg!=NULL)){ result=irc_cmd_msg(session,nch,msg); } } } lua_pushinteger(L,result); return 1; }
void event_join (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) { if ( !origin ) return; if(bnick == false) { printf("\nVerbunden."); snprintf (textbuf, sizeof(textbuf), "Hi all! =)"); printf("\n--------------------------------------------------\n"); FILE * datei; size_t len; char text[100]; datei = fopen("/etc/ircbotF/confi.cfg", "r"); if( datei != NULL) { fgets(text,100,datei); len = strlen(text); text[len-1] = '\0'; fclose(datei); } char pfad[255]; snprintf(pfad, sizeof(pfad),"%slog/lastlog.txt",text); FILE * newtxt = fopen(pfad,"a"); fclose(newtxt); bnick = true; } else { snprintf (textbuf, sizeof(textbuf), "Hi %s! =)", origin); } irc_cmd_msg (session, params[0], textbuf); snprintf(textbuf, sizeof(textbuf), "JOIN: <%s> '%s'", origin, ichanel); dlop(textbuf,true); }
void botcmd_greet(irc_session_t* session, const char* send_to, const char* channel) { char buf[256]; char greet[256]; char send_to_c[256]; strcpy(send_to_c, send_to); str_trim(send_to_c); if (greeter_on) { greeter_get(greet); if (strlen(greet) > 0) { sprintf(buf, greet, send_to_c); irc_cmd_msg(session, channel, buf); } } }
void sql_geturl(irc_session_t *session,const char name[],int counter) { sqlite3_stmt *vm; sqlite3_prepare(sqlitedb, "SELECT * FROM urls ORDER BY id DESC", -1, &vm, NULL); int i = 0; //printf("ID:\tnick\tchannel\turl\n"); while (sqlite3_step(vm) != SQLITE_DONE) { char tmp[1200]; sprintf(tmp,"%s (%s - %s)",sqlite3_column_text(vm, 3),sqlite3_column_text(vm, 1),sqlite3_column_text(vm, 2)); irc_cmd_msg(session,name,tmp); i++; if(i==counter) break; } sqlite3_finalize(vm); }