diff options
author | Adam <Adam@anope.org> | 2010-11-26 10:15:48 -0600 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:36:19 -0500 |
commit | 2b10cc84eab6cb9253611a090eb3ef67a6d3d0a7 (patch) | |
tree | ba269569cc768e14aeb49f25d639a955055ad337 | |
parent | cb6ef574e3df5cc846247450b74ca37d265f319e (diff) |
Added /bs set msg
-rw-r--r-- | include/commands.h | 5 | ||||
-rw-r--r-- | include/language.h | 7 | ||||
-rw-r--r-- | include/services.h | 6 | ||||
-rw-r--r-- | modules/core/bs_info.cpp | 6 | ||||
-rw-r--r-- | modules/core/bs_set.cpp | 35 | ||||
-rw-r--r-- | modules/core/db_plain.cpp | 3 | ||||
-rw-r--r-- | modules/core/hs_list.cpp | 2 | ||||
-rw-r--r-- | modules/extra/db_mysql.cpp | 3 | ||||
-rw-r--r-- | src/command.cpp | 32 | ||||
-rw-r--r-- | src/language.cpp | 22 |
10 files changed, 108 insertions, 13 deletions
diff --git a/include/commands.h b/include/commands.h index e247fc388..9f4c5a928 100644 --- a/include/commands.h +++ b/include/commands.h @@ -57,9 +57,12 @@ struct CommandSource /* Whether or not this was a fantasy command */ bool fantasy; + std::list<Anope::string> reply; + + ~CommandSource(); + void Reply(LanguageString message, ...); void Reply(const char *message, ...); - void Reply(const Anope::string &message); }; /** Every services command is a class, inheriting from Command. diff --git a/include/language.h b/include/language.h index 0b183598b..0b880a2f5 100644 --- a/include/language.h +++ b/include/language.h @@ -781,6 +781,7 @@ enum LanguageString BOT_INFO_CHAN_KICK_UNDERLINES_BAN, BOT_INFO_CHAN_KICK_ITALICS, BOT_INFO_CHAN_KICK_ITALICS_BAN, + BOT_INFO_CHAN_MSG, BOT_INFO_ACTIVE, BOT_INFO_INACTIVE, BOT_INFO_CHAN_OPTIONS, @@ -815,6 +816,11 @@ enum LanguageString BOT_SET_SYMBIOSIS_SYNTAX, BOT_SET_SYMBIOSIS_ON, BOT_SET_SYMBIOSIS_OFF, + BOT_SET_MSG_SYNTAX, + BOT_SET_MSG_OFF, + BOT_SET_MSG_PRIVMSG, + BOT_SET_MSG_NOTICE, + BOT_SET_MSG_NOTICEOPS, BOT_KICK_SYNTAX, BOT_KICK_DISABLED, BOT_KICK_UNKNOWN, @@ -1496,6 +1502,7 @@ enum LanguageString BOT_HELP_SET_FANTASY, BOT_HELP_SET_GREET, BOT_HELP_SET_SYMBIOSIS, + BOT_HELP_SET_MSG, BOT_HELP_KICK, BOT_HELP_KICK_BOLDS, BOT_HELP_KICK_COLORS, diff --git a/include/services.h b/include/services.h index 61532b82d..16be4ebc7 100644 --- a/include/services.h +++ b/include/services.h @@ -698,6 +698,12 @@ enum BotServFlag BS_KICK_REPEAT, /* BotServ kicks for italics */ BS_KICK_ITALICS, + /* Send fantasy replies back to the channel via PRIVMSG */ + BS_MSG_PRIVMSG, + /* Send fantasy replies back to the channel via NOTICE */ + BS_MSG_NOTICE, + /* Send fantasy replies back to the channel via NOTICE to ops */ + BS_MSG_NOTICEOPS, BS_END }; diff --git a/modules/core/bs_info.cpp b/modules/core/bs_info.cpp index 0a86748c3..7c3ea2ef9 100644 --- a/modules/core/bs_info.cpp +++ b/modules/core/bs_info.cpp @@ -162,6 +162,12 @@ class CommandBSInfo : public Command } else source.Reply(BOT_INFO_CHAN_KICK_ITALICS, GetString(u, BOT_INFO_INACTIVE).c_str()); + if (ci->botflags.HasFlag(BS_MSG_PRIVMSG)) + source.Reply(BOT_INFO_CHAN_MSG, "PRIVMSG"); + else if (ci->botflags.HasFlag(BS_MSG_NOTICE)) + source.Reply(BOT_INFO_CHAN_MSG, "NOTICE"); + else if (ci->botflags.HasFlag(BS_MSG_NOTICEOPS)) + source.Reply(BOT_INFO_CHAN_MSG, "NOTICEOPS"); end = buf; *end = 0; diff --git a/modules/core/bs_set.cpp b/modules/core/bs_set.cpp index 99cf6c415..b9e06a4db 100644 --- a/modules/core/bs_set.cpp +++ b/modules/core/bs_set.cpp @@ -157,6 +157,39 @@ class CommandBSSet : public Command else SyntaxError(BotServ, u, "SET SYMBIOSIS", BOT_SET_SYMBIOSIS_SYNTAX); } + else if (option.equals_ci("MSG")) + { + if (value.equals_ci("OFF")) + { + ci->botflags.UnsetFlag(BS_MSG_PRIVMSG); + ci->botflags.UnsetFlag(BS_MSG_NOTICE); + ci->botflags.UnsetFlag(BS_MSG_NOTICEOPS); + source.Reply(BOT_SET_MSG_OFF, ci->name.c_str()); + } + else if (value.equals_ci("PRIVMSG")) + { + ci->botflags.SetFlag(BS_MSG_PRIVMSG); + ci->botflags.UnsetFlag(BS_MSG_NOTICE); + ci->botflags.UnsetFlag(BS_MSG_NOTICEOPS); + source.Reply(BOT_SET_MSG_PRIVMSG, ci->name.c_str()); + } + else if (value.equals_ci("NOTICE")) + { + ci->botflags.UnsetFlag(BS_MSG_PRIVMSG); + ci->botflags.SetFlag(BS_MSG_NOTICE); + ci->botflags.UnsetFlag(BS_MSG_NOTICEOPS); + source.Reply(BOT_SET_MSG_NOTICE, ci->name.c_str()); + } + else if (value.equals_ci("NOTICEOPS")) + { + ci->botflags.UnsetFlag(BS_MSG_PRIVMSG); + ci->botflags.UnsetFlag(BS_MSG_NOTICE); + ci->botflags.SetFlag(BS_MSG_NOTICEOPS); + source.Reply(BOT_SET_MSG_NOTICEOPS, ci->name.c_str()); + } + else + SyntaxError(BotServ, u, "SET MSG", BOT_SET_MSG_SYNTAX); + } else source.Reply(BOT_SET_UNKNOWN, option.c_str()); } @@ -186,6 +219,8 @@ class CommandBSSet : public Command u->SendMessage(BotServ, BOT_SERVADMIN_HELP_SET_NOBOT); else if (subcommand.equals_ci("PRIVATE")) u->SendMessage(BotServ, BOT_SERVADMIN_HELP_SET_PRIVATE); + else if (subcommand.equals_ci("MSG")) + u->SendMessage(BotServ, BOT_HELP_SET_MSG); else return false; diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp index 953f35b4a..2c655b7d9 100644 --- a/modules/core/db_plain.cpp +++ b/modules/core/db_plain.cpp @@ -305,6 +305,9 @@ BotFlagInfo BotFlags[] = { {"KICK_FLOOD", BS_KICK_FLOOD}, {"KICK_REPEAT", BS_KICK_REPEAT}, {"KICK_ITALICS", BS_KICK_ITALICS}, + {"MSG_PRIVMSG", BS_MSG_PRIVMSG}, + {"MSG_NOTICE", BS_MSG_NOTICE}, + {"MSG_NOTICEOPS", BS_MSG_NOTICEOPS}, {"", static_cast<BotServFlag>(-1)} }; diff --git a/modules/core/hs_list.cpp b/modules/core/hs_list.cpp index 543aa273a..23ce31f9a 100644 --- a/modules/core/hs_list.cpp +++ b/modules/core/hs_list.cpp @@ -22,8 +22,6 @@ class CommandHSList : public Command CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - User *u = source.u; - const Anope::string &key = !params.empty() ? params[0] : ""; int from = 0, to = 0, counter = 1; unsigned display_counter = 0; diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp index 8298fcbdf..b2f60236b 100644 --- a/modules/extra/db_mysql.cpp +++ b/modules/extra/db_mysql.cpp @@ -73,6 +73,9 @@ BotFlagInfo BotFlags[] = { {"KICK_FLOOD", BS_KICK_FLOOD}, {"KICK_REPEAT", BS_KICK_REPEAT}, {"KICK_ITALICS", BS_KICK_ITALICS}, + {"MSG_PRIVMSG", BS_MSG_PRIVMSG}, + {"MSG_NOTICE", BS_MSG_NOTICE}, + {"MSG_NOTICEOPS", BS_MSG_NOTICEOPS}, {"", static_cast<BotServFlag>(-1)} }; diff --git a/src/command.cpp b/src/command.cpp index 91e4507db..d71685f4f 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -8,6 +8,26 @@ #include "services.h" #include "modules.h" +CommandSource::~CommandSource() +{ + for (std::list<Anope::string>::iterator it = this->reply.begin(), it_end = this->reply.end(); it != it_end; ++it) + { + const Anope::string &message = *it; + + // Send to the user if the reply is more than one line + if (!this->fantasy || !this->ci || this->reply.size() > 1) + u->SendMessage(this->service->nick, message); + else if (this->ci->botflags.HasFlag(BS_MSG_PRIVMSG)) + ircdproto->SendPrivmsg(this->service, this->ci->name, message.c_str()); + else if (this->ci->botflags.HasFlag(BS_MSG_NOTICE)) + ircdproto->SendNotice(this->service, this->ci->name, message.c_str()); + else if (this->ci->botflags.HasFlag(BS_MSG_NOTICEOPS)) + ircdproto->SendNoticeChanops(this->service, this->ci->c, message.c_str()); + else + u->SendMessage(this->service->nick, message); + } +} + void CommandSource::Reply(LanguageString message, ...) { Anope::string m = GetString(this->u, message); @@ -27,7 +47,7 @@ void CommandSource::Reply(LanguageString message, ...) Anope::string line; while (sep.GetToken(line)) - this->Reply(line.empty() ? " " : line); + this->Reply(line.empty() ? " " : line.c_str()); } void CommandSource::Reply(const char *message, ...) @@ -40,20 +60,12 @@ void CommandSource::Reply(const char *message, ...) va_start(args, message); vsnprintf(buf, BUFSIZE - 1, message, args); - this->Reply(Anope::string(buf)); + this->reply.push_back(message); va_end(args); } } -void CommandSource::Reply(const Anope::string &message) -{ - if (this->fantasy && this->ci) - ircdproto->SendPrivmsg(this->service, this->ci->name, message.c_str()); - else - u->SendMessage(this->service->nick, message); -} - Command::Command(const Anope::string &sname, size_t min_params, size_t max_params, const Anope::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission) { this->module = NULL; diff --git a/src/language.cpp b/src/language.cpp index 4ab89c567..ea6f37ee8 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -1763,6 +1763,8 @@ const char *const language_strings[LANG_STRING_COUNT] = { _(" Italics kicker : %s"), /* BOT_INFO_CHAN_KICK_ITALICS_BAN */ _(" Italics kicker : %s (%d kick(s) to ban)"), + /* BOT_INFO_CHAN_MSG */ + _(" Fantasy reply : %s"), /* BOT_INFO_ACTIVE */ _("enabled"), /* BOT_INFO_INACTIVE */ @@ -1832,6 +1834,16 @@ const char *const language_strings[LANG_STRING_COUNT] = { _("Symbiosis mode is now ON on channel %s."), /* BOT_SET_SYMBIOSIS_OFF */ _("Symbiosis mode is now OFF on channel %s."), + /* BOT_SET_MSG_SYNTAX */ + _("SET \037channel\037 MSG {\037OFF|PRIVMSG|NOTICE|NOTICEOPS\037}"), + /* BOT_SET_MSG_OFF */ + _("Fantasy replies will no longer be sent to %s."), + /* BOT_SET_MSG_PRIVMSG */ + _("Fantasy replies will be sent via PRIVMSG to %s."), + /* BOT_SET_MSG_NOTICE */ + _("Fantasy replies will be sent via NOTICE to %s."), + /* BOT_SET_MSG_NOTICEOPS */ + _("Fantasy replies will be sent via NOTICE to channel ops on %s."), /* BOT_KICK_SYNTAX */ _("KICK channel option {ON|OFF} [settings]"), /* BOT_KICK_DISABLED */ @@ -4879,6 +4891,7 @@ const char *const language_strings[LANG_STRING_COUNT] = { " GREET Enable greet messages\n" " FANTASY Enable fantaisist commands\n" " SYMBIOSIS Allow the bot to act as a real bot\n" + " MSG Configure how fantasy commands should be replied to\n" " \n" "Type %R%S HELP SET option for more information\n" "on a specific option.\n" @@ -4925,6 +4938,15 @@ const char *const language_strings[LANG_STRING_COUNT] = { "When it is enabled, the bot will do everything\n" "normally done by %s on channels, such as MODEs,\n" "KICKs, and even the entry message."), + /* BOT_HELP_SET_MSG */ + _("Syntax: \002SET \037channel\037 MSG {\037OFF|PRIVMSG|NOTICE|NOTICEOPS\037}\002\n" + " \n" + "Configures how fantasy commands should be returned to the channel. Off disables\n" + "fantasy from replying to the channel. Privmsg, notice, and noticeops message the\n" + "channel, notice the channel, and notice the channel ops respectively.\n" + " \n" + "Note that replies over one line will not use this setting to prevent spam, and will\n" + "go directly to the user who executed it."), /* BOT_HELP_KICK */ _("Syntax: KICK channel option parameters\n" " \n" |