@@ -410,15 +410,17 @@ void ApplyToChan(const ChanTrapInfo *ct, Channel *c)
410410 }
411411}
412412
413- void CreateChan (const ChanTrapInfo *ct, bool created )
413+ bool CreateChan (const ChanTrapInfo *ct)
414414{
415- ChannelStatus status (Config->GetModule (" BotServ" )->Get <Anope::string>(" botmodes" , " ao" ));
416-
417415 if (ct->bots == 0 )
418- return ;
416+ return false ;
419417
420- /* Create or take over the channel (remove modes then set ours) */
418+ ChannelStatus status (Config->GetModule (" BotServ" )->Get <Anope::string>(" botmodes" , " ao" ));
419+ bool created = false ;
420+
421+ /* Create or takeover the channel, remove users and change modes as needed. */
421422 Channel *c = Channel::FindOrCreate (ct->mask , created);
423+ OperServ->Join (c, &status);
422424 if (!created)
423425 {
424426 for (Channel::ModeList::const_iterator it = c->GetModes ().begin (); it != c->GetModes ().end (); )
@@ -430,9 +432,6 @@ void CreateChan(const ChanTrapInfo *ct, bool created)
430432 }
431433 }
432434 c->SetModes (OperServ, false , ct->modes .c_str ());
433-
434- /* Join OperServ to hold the channel while we zap any existing users (if needed) */
435- OperServ->Join (c, &status);
436435 if (!created)
437436 ApplyToChan (ct, c);
438437
@@ -441,7 +440,7 @@ void CreateChan(const ChanTrapInfo *ct, bool created)
441440 for (botinfo_map::const_iterator it = BotListByNick->begin (), it_end = BotListByNick->end (); it != it_end; ++it)
442441 {
443442 if (joined == ct->bots )
444- return ;
443+ return created ;
445444
446445 BotInfo *bi = it->second ;
447446 if (!bi || bi->nick .equals_ci (" OperServ" ))
@@ -458,7 +457,7 @@ void CreateChan(const ChanTrapInfo *ct, bool created)
458457 for (std::map<const CreatedBotInfo *, unsigned >::const_iterator it = bots.begin (), it_end = bots.end (); it != it_end; ++it)
459458 {
460459 if (joined == ct->bots )
461- return ;
460+ return created ;
462461
463462 const CreatedBotInfo *cbi = it->first ;
464463 if (cbi)
@@ -483,6 +482,8 @@ void CreateChan(const ChanTrapInfo *ct, bool created)
483482 }
484483 while (joined < ct->bots );
485484 }
485+
486+ return created;
486487}
487488
488489const unsigned FindMatches (const ChanTrapInfo *ct)
@@ -523,12 +524,21 @@ class CommandOSChanTrap : public Command
523524 }
524525
525526 mask = params[1 ];
526- bots = convertTo<unsigned >(params[2 ]);
527527 saction = params[3 ];
528528 sduration = params[4 ];
529529 modes = params[5 ];
530530 reason = params[6 ];
531531
532+ try
533+ {
534+ bots = convertTo<unsigned >(params[2 ]);
535+ }
536+ catch (const ConvertException &)
537+ {
538+ source.Reply (" Invalid number of bots: '%s' is not valid for number of bots." , params[2 ].c_str ());
539+ return ;
540+ }
541+
532542 if (bots == 0 && mask.replace_all_cs (" ?*" , " " ).empty ())
533543
534544 {
@@ -714,7 +724,7 @@ class CommandOSChanTrap : public Command
714724 if (c)
715725 matched = true ;
716726
717- CreateChan (ct, NULL );
727+ CreateChan (ct);
718728
719729 ChannelInfo *ci = ChannelInfo::Find (ct->mask );
720730 if (ci)
@@ -1027,10 +1037,7 @@ class OSChanTrap : public Module
10271037 matched_chans += FindMatches (ct);
10281038 else
10291039 {
1030- bool cr = false ;
1031- CreateChan (ct, cr);
1032-
1033- if (cr)
1040+ if (CreateChan (ct))
10341041 created_chans++;
10351042 else
10361043 matched_chans++;
@@ -1051,7 +1058,7 @@ class OSChanTrap : public Module
10511058 throw ModuleException (" Requires version 2.0.x of Anope." );
10521059
10531060 this ->SetAuthor (" genius3000" );
1054- this ->SetVersion (" 1.0.0 " );
1061+ this ->SetVersion (" 1.0.2 " );
10551062
10561063 if (Me && Me->IsSynced ())
10571064 this ->Init ();
@@ -1060,8 +1067,8 @@ class OSChanTrap : public Module
10601067 void OnReload (Configuration::Conf *conf) anope_override
10611068 {
10621069 OperServ = conf->GetClient (" OperServ" );
1063- kill_reason = conf->GetModule (this )->Get <Anope::string>(" kill_reason " , " I know what you did last join!" );
1064- akill_reason = conf->
GetModule (
this )->
Get <Anope::string>(
" akill_reason " ,
" Joined a spambot trap channel - contact [email protected] if in error. " );
1070+ kill_reason = conf->GetModule (this )->Get <Anope::string>(" killreason " , " I know what you did last join!" );
1071+ akill_reason = conf->GetModule (this )->Get <Anope::string>(" akillreason " , " You found yourself a disappearing act! " );
10651072 }
10661073
10671074 void OnUplinkSync (Server *) anope_override
0 commit comments