diff options
| author | Adam <Adam@anope.org> | 2011-01-15 16:11:31 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2011-01-15 16:11:31 -0500 |
| commit | c669820481b8c431f4238d6b2d958e9dbfec411a (patch) | |
| tree | eaa7e25756bed697553db9529cb490dc954a73a3 /modules | |
| parent | ecc2fc6029567d1d2f4d02d36bf64216ae9a03ee (diff) | |
Added an amsg kicker
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/core/bs_kick.cpp | 66 | ||||
| -rw-r--r-- | modules/extra/db_mysql_live.cpp | 39 | ||||
| -rw-r--r-- | modules/protocol/unreal32.cpp | 2 |
3 files changed, 88 insertions, 19 deletions
diff --git a/modules/core/bs_kick.cpp b/modules/core/bs_kick.cpp index 1618e1d1b..fef71e9f6 100644 --- a/modules/core/bs_kick.cpp +++ b/modules/core/bs_kick.cpp @@ -365,6 +365,36 @@ class CommandBSKick : public Command source.Reply(BOT_KICK_ITALICS_OFF); } } + else if (option.equals_ci("AMSGS")) + { + if (value.equals_ci("ON")) + { + if (!ttb.empty()) + { + Anope::string error; + ci->ttb[TTB_AMSGS] = convertTo<int16>(ttb, error, false); + if (!error.empty() || ci->ttb[TTB_AMSGS] < 0) + { + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_ITALICS]; + ci->ttb[TTB_AMSGS] = 0; + source.Reply(BOT_KICK_AMSGS_ON_BAN, ci->ttb[TTB_AMSGS]); + return MOD_CONT; + } + } + else + ci->ttb[TTB_AMSGS] = 0; + ci->botflags.SetFlag(BS_KICK_AMSGS); + if (ci->ttb[TTB_AMSGS]) + source.Reply(BOT_KICK_AMSGS_ON_BAN, ci->ttb[TTB_AMSGS]); + else + source.Reply(BOT_KICK_AMSGS_ON); + } + else + { + ci->botflags.UnsetFlag(BS_KICK_AMSGS); + source.Reply(BOT_KICK_AMSGS_OFF); + } + } else source.Reply(BOT_KICK_UNKNOWN, option.c_str()); } @@ -393,6 +423,8 @@ class CommandBSKick : public Command source.Reply(BOT_HELP_KICK_UNDERLINES); else if (subcommand.equals_ci("ITALICS")) source.Reply(BOT_HELP_KICK_ITALICS); + else if (subcommand.equals_ci("AMSGS")) + source.Reply(BOT_HELP_KICK_AMSGS); else return false; @@ -421,6 +453,40 @@ class BSKick : public Module this->SetType(CORE); this->AddCommand(BotServ, &commandbskick); + + ModuleManager::Attach(I_OnPrivmsg, this); + } + + EventReturn OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg, bool &Allow) + { + Anope::string m, ch; + time_t time; + + if (u->GetExtRegular("bs_kick_lastmsg", m) && u->GetExtRegular("bs_kick_lasttime", time) && u->GetExtRegular("bs_kick_lastchan", ch)) + { + if (time == Anope::CurTime && m == msg && ch != ci->name) + { + for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end();) + { + Channel *c = (*it)->chan; + ++it; + + if (c->ci != NULL) + { + check_ban(c->ci, u, TTB_AMSGS); + bot_kick(c->ci, u, BOT_REASON_AMSGS); + } + } + + return EVENT_CONTINUE; + } + } + + u->Extend("bs_kick_lastmsg", new ExtensibleItemRegular<Anope::string>(msg)); + u->Extend("bs_kick_lasttime", new ExtensibleItemRegular<time_t>(Anope::CurTime)); + u->Extend("bs_kick_lastchan", new ExtensibleItemRegular<Anope::string>(ci->name)); + + return EVENT_CONTINUE; } }; diff --git a/modules/extra/db_mysql_live.cpp b/modules/extra/db_mysql_live.cpp index f110b631d..bf5a1e6f7 100644 --- a/modules/extra/db_mysql_live.cpp +++ b/modules/extra/db_mysql_live.cpp @@ -85,30 +85,33 @@ class MySQLLiveModule : public Module, public Pipe EventReturn OnPreCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) { - CommandMutex *cm = new CommandMutex(); - try + if (this->SQL) { - cm->mutex.Lock(); - cm->command = command; - cm->source = source; - cm->params = params; + CommandMutex *cm = new CommandMutex(); + try + { + cm->mutex.Lock(); + cm->command = command; + cm->source = source; + cm->params = params; - commands.push_back(cm); + commands.push_back(cm); - // Give processing to the command thread - Log(LOG_DEBUG_2) << "db_mysql_live: Waiting for command thread " << cm->command->name << " from " << source.u->nick; - threadEngine.Start(cm); - main_mutex.Lock(); - } - catch (const CoreException &ex) - { - delete cm; - Log() << "db_mysql_live: Unable to thread for command: " << ex.GetReason(); + // Give processing to the command thread + Log(LOG_DEBUG_2) << "db_mysql_live: Waiting for command thread " << cm->command->name << " from " << source.u->nick; + threadEngine.Start(cm); + main_mutex.Lock(); - return EVENT_CONTINUE; + return EVENT_STOP; + } + catch (const CoreException &ex) + { + delete cm; + Log() << "db_mysql_live: Unable to thread for command: " << ex.GetReason(); + } } - return EVENT_STOP; + return EVENT_CONTINUE; } void OnNotify() diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp index 6db84639b..d02987038 100644 --- a/modules/protocol/unreal32.cpp +++ b/modules/protocol/unreal32.cpp @@ -1043,7 +1043,7 @@ class ProtoUnreal : public Module message_mode("G", OnMode), message_nick("&", OnNick), message_part("D", OnPart), message_ping("8", OnPing), message_pong("PONG", event_pong), - message_pong2("9", event_pong), message_privmsg("!", OnPrivmsg), + message_pong2("9", event_pong), message_privmsg("!", ::OnPrivmsg), message_quit(",", OnQuit), message_server("'", OnServer), message_squit("-", OnSQuit), message_topic(")", OnTopic), message_svsmode("SVSMODE", OnMode), |
