mirror of
https://github.com/anope/anope.git
synced 2026-07-03 10:33:13 +02:00
Added /bs set msg
This commit is contained in:
+4
-1
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)}
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)}
|
||||
};
|
||||
|
||||
|
||||
+22
-10
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user