void check_botinfo(BotInfo *binfo, const char *channel) { Chan *chan; ChanUser *cu; Mech *backup; char *userhost; userhost = getuh(binfo->nuh); backup = current; for(current=botlist;current;current=current->next) { for(chan=current->chanlist;chan;chan=chan->next) { if (channel && Strcasecmp(channel,chan->name)) continue; if ((cu = find_chanbot(chan,binfo->nuh)) == NULL) continue; if (!Strcasecmp(cu->userhost,userhost)) { cu->flags |= CU_NEEDOP; send_mode(chan,50,QM_CHANUSER,'+','o',(void*)cu); } } } current = backup; }
void check_botjoin(Chan *chan, ChanUser *cu) { BotNet *bn; BotInfo *binfo; #ifdef DEBUG debug("(check_botjoin) chan = %s; cu = %s!%s\n",chan->name,cu->nick,cu->userhost); #endif /* DEBUG */ for(bn=botnetlist;bn;bn=bn->next) { if (bn->status != BN_LINKED) continue; for(binfo=bn->botinfo;binfo;binfo=binfo->next) { if (!nickcmp(cu->nick,binfo->nuh) && !Strcasecmp(cu->userhost,getuh(binfo->nuh))) { if ((cu = find_chanbot(chan,binfo->nuh)) == NULL) return; cu->flags |= CU_NEEDOP; send_mode(chan,50,QM_CHANUSER,'+','o',(void*)cu); #ifdef DEBUG debug("(check_botjoin) CU_NEEDOP set, mode pushed\n"); #endif /* DEBUG */ return; } } } }
void loadbotservdb() { char nick[NICKLEN+1]; char ident[NICKLEN+1]; char host[HOSTLEN+1]; char chan[CHANLEN+1]; MYSQL_RES *result; MYSQL_ROW row; if (!reconnect_to_db()) { fprintf(stderr,"Cannot connect to db\n"); operlog("Cannot connect to db"); return; } mysql_query(&mysql,"SELECT * FROM child_botserv_bots"); if ((result = mysql_use_result(&mysql)) == NULL) { fprintf(stderr,"CRITICAL: Cannot load botserv bots table: mysql_use_result returned NULL\n"); return; } while ((row = mysql_fetch_row(result))) { strncpy(nick,row[0],NICKLEN); strncpy(ident,row[1],NICKLEN); strncpy(host,row[2],HOSTLEN); if (find_bot(nick)) continue; addBot(nick,ident,host); if (vv) printf("Bot %s added (%s@%s)\n",nick,ident,host); } mysql_query(&mysql,"SELECT * FROM child_botserv_chans"); if ((result = mysql_use_result(&mysql)) == NULL) { fprintf(stderr,"CRITICAL: Cannot load botserv chans table: mysql_use_result returned NULL\n"); return; } while ((row = mysql_fetch_row(result))) { strncpy(chan,row[0],CHANLEN); strncpy(nick,row[1],NICKLEN); if (find_chanbot(chan)) continue; if (!find_bot(nick)) continue; if (!find_channel(chan)) continue; addChanbot(chan,nick); if (vv) printf("Chanbot %s added with bot %s\n",chan,nick); } mysql_close(&mysql); }