tidy up dead channel handling and remove test code

This commit is contained in:
Mark 2004-08-26 21:55:02 +00:00
parent 3ff0851bc2
commit db03f7026c

View file

@ -638,10 +638,11 @@ Bot *init_bot (BotInfo* botinfo)
void handle_dead_channel (Channel *c)
{
CmdParams* cmdparams;
lnode_t *cm;
Bot *botptr;
hnode_t *bn;
hscan_t bs;
lnode_t *cm;
char *chan;
SET_SEGV_LOCATION();
if (ircstrcasecmp(c->name, me.serviceschan) == 0) {
@ -653,26 +654,21 @@ void handle_dead_channel (Channel *c)
}
hash_scan_begin (&bs, bothash);
cmdparams = ns_calloc (sizeof (CmdParams));
cmdparams->channel = c;
while ((bn = hash_scan_next (&bs)) != NULL) {
botptr = hnode_get (bn);
restart:
cm = list_first (botptr->u->user->chans);
if (!(botptr->u->user->Umode & UMODE_DEAF)) {
while (cm) {
char* chan;
chan = (char *) lnode_get (cm);
cmdparams->bot = botptr;
cmdparams->channel = c;
if (ircstrcasecmp(c->name, chan) == 0) {
cm = list_first (cmdparams->bot->u->user->chans);
while (cm) {
chan = (char *) lnode_get (cm);
if (ircstrcasecmp (cmdparams->channel->name, chan) == 0) {
/* Force the bot to leave the channel */
irc_part (botptr, c->name);
irc_part (cmdparams->bot, cmdparams->channel->name);
/* Tell the module we kicked them out */
SendModuleEvent (EVENT_EMPTYCHAN, cmdparams, botptr->moduleptr);
goto restart;
}
cm = list_next (botptr->u->user->chans, cm);
SendModuleEvent (EVENT_EMPTYCHAN, cmdparams, cmdparams->bot->moduleptr);
break;
}
cm = list_next (cmdparams->bot->u->user->chans, cm);
}
}
free (cmdparams);