tidy up dead channel handling and remove test code
This commit is contained in:
parent
3ff0851bc2
commit
db03f7026c
1 changed files with 20 additions and 24 deletions
26
src/bots.c
26
src/bots.c
|
@ -638,10 +638,11 @@ Bot *init_bot (BotInfo* botinfo)
|
||||||
void handle_dead_channel (Channel *c)
|
void handle_dead_channel (Channel *c)
|
||||||
{
|
{
|
||||||
CmdParams* cmdparams;
|
CmdParams* cmdparams;
|
||||||
lnode_t *cm;
|
|
||||||
Bot *botptr;
|
Bot *botptr;
|
||||||
hnode_t *bn;
|
hnode_t *bn;
|
||||||
hscan_t bs;
|
hscan_t bs;
|
||||||
|
lnode_t *cm;
|
||||||
|
char *chan;
|
||||||
|
|
||||||
SET_SEGV_LOCATION();
|
SET_SEGV_LOCATION();
|
||||||
if (ircstrcasecmp(c->name, me.serviceschan) == 0) {
|
if (ircstrcasecmp(c->name, me.serviceschan) == 0) {
|
||||||
|
@ -653,26 +654,21 @@ void handle_dead_channel (Channel *c)
|
||||||
}
|
}
|
||||||
hash_scan_begin (&bs, bothash);
|
hash_scan_begin (&bs, bothash);
|
||||||
cmdparams = ns_calloc (sizeof (CmdParams));
|
cmdparams = ns_calloc (sizeof (CmdParams));
|
||||||
|
cmdparams->channel = c;
|
||||||
while ((bn = hash_scan_next (&bs)) != NULL) {
|
while ((bn = hash_scan_next (&bs)) != NULL) {
|
||||||
botptr = hnode_get (bn);
|
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->bot = botptr;
|
||||||
cmdparams->channel = c;
|
cm = list_first (cmdparams->bot->u->user->chans);
|
||||||
if (ircstrcasecmp(c->name, chan) == 0) {
|
while (cm) {
|
||||||
|
chan = (char *) lnode_get (cm);
|
||||||
|
if (ircstrcasecmp (cmdparams->channel->name, chan) == 0) {
|
||||||
/* Force the bot to leave the channel */
|
/* 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 */
|
/* Tell the module we kicked them out */
|
||||||
SendModuleEvent (EVENT_EMPTYCHAN, cmdparams, botptr->moduleptr);
|
SendModuleEvent (EVENT_EMPTYCHAN, cmdparams, cmdparams->bot->moduleptr);
|
||||||
goto restart;
|
break;
|
||||||
}
|
|
||||||
cm = list_next (botptr->u->user->chans, cm);
|
|
||||||
}
|
}
|
||||||
|
cm = list_next (cmdparams->bot->u->user->chans, cm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (cmdparams);
|
free (cmdparams);
|
||||||
|
|
Reference in a new issue