mirror of
https://github.com/anope/anope.git
synced 2026-07-05 03:33:12 +02:00
Split up bs_set
This commit is contained in:
@@ -248,3 +248,63 @@ command { service = "BotServ"; name = "KICK"; command = "botserv/kick"; }
|
||||
module { name = "bs_set" }
|
||||
command { service = "BotServ"; name = "SET"; command = "botserv/set"; }
|
||||
|
||||
/*
|
||||
* bs_set_dontkickops
|
||||
*
|
||||
* Provides the command botserv/set/dontkickops.
|
||||
*
|
||||
* Used for preventing BotServ from kicking channel operators.
|
||||
*/
|
||||
module { name = "bs_set_dontkickops" }
|
||||
command { service = "BotServ"; name = "SET DONTKICKOPS"; command = "botserv/set/dontkickops"; }
|
||||
|
||||
/*
|
||||
* bs_set_dontkickvoices
|
||||
*
|
||||
* Provides the command botserv/set/dontkickvoices.
|
||||
*
|
||||
* Used for preventing BotServ from kicking voices.
|
||||
*/
|
||||
module { name = "bs_set_dontkickvoices" }
|
||||
command { service = "BotServ"; name = "SET DONTKICKVOICES"; command = "botserv/set/dontkickvoices"; }
|
||||
|
||||
/*
|
||||
* bs_set_fantasy
|
||||
*
|
||||
* Provides the command botserv/set/fantasy.
|
||||
*
|
||||
* Used for enabling or disabling BotServ's fantaisist commands.
|
||||
*/
|
||||
module { name = "bs_set_fantasy" }
|
||||
command { service = "BotServ"; name = "SET FANTASY"; command = "botserv/set/fantasy"; }
|
||||
|
||||
/*
|
||||
* bs_set_greet
|
||||
*
|
||||
* Provides the command botserv/set/greet.
|
||||
*
|
||||
* Used for enabling or disabling BotServ's greet messages in a channel.
|
||||
*/
|
||||
module { name = "bs_set_greet" }
|
||||
command { service = "BotServ"; name = "SET GREET"; command = "botserv/set/greet"; }
|
||||
|
||||
/*
|
||||
* bs_set_nobot
|
||||
*
|
||||
* Provides the command botserv/set/nobot.
|
||||
*
|
||||
* Used by Services Operators to prohibit specific channels from assigning BotServ bots.
|
||||
*/
|
||||
module { name = "bs_set_nobot" }
|
||||
command { service = "BotServ"; name = "SET NOBOT"; command = "botserv/set/nobot"; }
|
||||
|
||||
/*
|
||||
* bs_set_private
|
||||
*
|
||||
* Provides the command botserv/set/private.
|
||||
*
|
||||
* Used by Services Operators to prohibit specific BotServ bots from being assigned to channels.
|
||||
*/
|
||||
module { name = "bs_set_private" }
|
||||
command { service = "BotServ"; name = "SET PRIVATE"; command = "botserv/set/private"; }
|
||||
|
||||
|
||||
+22
-211
@@ -19,230 +19,41 @@ class CommandBSSet : public Command
|
||||
CommandBSSet(Module *creator) : Command(creator, "botserv/set", 3, 3)
|
||||
{
|
||||
this->SetDesc(_("Configures bot options"));
|
||||
this->SetSyntax(_("\037(channel | bot)\037 \037option\037 \037settings\037"));
|
||||
this->SetSyntax(_("\037option\037 \037(channel | bot)\037 \037settings\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
const Anope::string &option = params[1];
|
||||
const Anope::string &value = params[2];
|
||||
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci;
|
||||
|
||||
if (readonly)
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
else if (u->HasCommand("botserv/set/private") && option.equals_ci("PRIVATE"))
|
||||
{
|
||||
BotInfo *bi;
|
||||
|
||||
if (!(bi = findbot(chan)))
|
||||
{
|
||||
source.Reply(BOT_DOES_NOT_EXIST, chan.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bi->SetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002on\002."), bi->nick.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bi->UnsetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002off\002."), bi->nick.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "PRIVATE");
|
||||
return;
|
||||
}
|
||||
else if (!(ci = cs_findchan(chan)))
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
else if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << option << " " << value;
|
||||
|
||||
if (option.equals_ci("DONTKICKOPS"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_DONTKICKOPS);
|
||||
source.Reply(_("Bot \002won't kick ops\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_DONTKICKOPS);
|
||||
source.Reply(_("Bot \002will kick ops\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "DONTKICKOPS");
|
||||
}
|
||||
else if (option.equals_ci("DONTKICKVOICES"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_DONTKICKVOICES);
|
||||
source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_DONTKICKVOICES);
|
||||
source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "DONTKICKVOICE");
|
||||
}
|
||||
else if (option.equals_ci("FANTASY"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "FANTASY");
|
||||
}
|
||||
else if (option.equals_ci("GREET"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "GREET");
|
||||
}
|
||||
else if (u->HasCommand("botserv/set/nobot") && option.equals_ci("NOBOT"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_NOBOT);
|
||||
if (ci->bi)
|
||||
ci->bi->UnAssign(u, ci);
|
||||
source.Reply(_("No Bot mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_NOBOT);
|
||||
source.Reply(_("No Bot mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "NOBOT");
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
|
||||
return;
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
if (subcommand.empty())
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Configures bot options.\n"
|
||||
" \n"
|
||||
"Available options:"));
|
||||
Anope::string this_name = source.command;
|
||||
for (BotInfo::command_map::const_iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Configures bot options. \037option\037 can be one of:\n"
|
||||
" \n"
|
||||
" DONTKICKOPS To protect ops against bot kicks\n"
|
||||
" DONTKICKVOICES To protect voices against bot kicks\n"
|
||||
" GREET Enable greet messages\n"
|
||||
" FANTASY Enable fantaisist commands\n"
|
||||
" \n"
|
||||
"Type \002%s%s HELP SET \037option\037\002 for more information\n"
|
||||
"on a specific option.\n"
|
||||
"Note: access to this command is controlled by the\n"
|
||||
"level SET."), Config->UseStrictPrivMsgString.c_str(), source.owner->nick.c_str());
|
||||
User *u = source.u;
|
||||
if (u->IsServicesOper())
|
||||
source.Reply(_("These options are reserved to Services Operators:\n"
|
||||
" \n"
|
||||
" NOBOT Prevent a bot from being assigned to \n"
|
||||
" a channel\n"
|
||||
" PRIVATE Prevent a bot from being assigned by\n"
|
||||
" non IRC operators"));
|
||||
const Anope::string &c_name = it->first;
|
||||
const CommandInfo &info = it->second;
|
||||
if (c_name.find_ci(this_name + " ") == 0)
|
||||
{
|
||||
service_reference<Command> command("Command", info.name);
|
||||
if (command)
|
||||
{
|
||||
source.command = it->first;
|
||||
command->OnServHelp(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (subcommand.equals_ci("DONTKICKOPS"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 DONTKICKOPS {\037ON|OFF\037}\n"
|
||||
" \n"
|
||||
"Enables or disables \002ops protection\002 mode on a channel.\n"
|
||||
"When it is enabled, ops won't be kicked by the bot\n"
|
||||
"even if they don't match the NOKICK level."));
|
||||
else if (subcommand.equals_ci("DONTKICKVOICES"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 DONTKICKVOICES {\037ON|OFF\037}\n"
|
||||
" \n"
|
||||
"Enables or disables \002voices protection\002 mode on a channel.\n"
|
||||
"When it is enabled, voices won't be kicked by the bot\n"
|
||||
"even if they don't match the NOKICK level."));
|
||||
else if (subcommand.equals_ci("FANTASY"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 FANTASY {\037ON|OFF\037}\n"
|
||||
"Enables or disables \002fantasy\002 mode on a channel.\n"
|
||||
"When it is enabled, users will be able to use\n"
|
||||
"%s commands on a channel when prefixed\n"
|
||||
"with one of the following fantasy characters: \002%s\002\n"
|
||||
" \n"
|
||||
"Note that users wanting to use fantaisist\n"
|
||||
"commands MUST have enough level for both\n"
|
||||
"the FANTASIA and another level depending\n"
|
||||
"of the command if required (for example, to use \n"
|
||||
"!op, user must have enough access for the OPDEOP\n"
|
||||
"level)."), Config->ChanServ.c_str(), Config->BSFantasyCharacter.c_str());
|
||||
else if (subcommand.equals_ci("GREET"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 GREET {\037ON|OFF\037}\n"
|
||||
" \n"
|
||||
"Enables or disables \002greet\002 mode on a channel.\n"
|
||||
"When it is enabled, the bot will display greet\n"
|
||||
"messages of users joining the channel, provided\n"
|
||||
"they have enough access to the channel."));
|
||||
else if (subcommand.equals_ci("NOBOT"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 NOBOT {\037ON|OFF\037}\002\n"
|
||||
" \n"
|
||||
"This option makes a channel be unassignable. If a bot \n"
|
||||
"is already assigned to the channel, it is unassigned\n"
|
||||
"automatically when you enable the option."));
|
||||
else if (subcommand.equals_ci("PRIVATE"))
|
||||
source.Reply(_("Syntax: \002SET \037bot-nick\037 PRIVATE {\037ON|OFF\037}\002\n"
|
||||
"This option prevents a bot from being assigned to a\n"
|
||||
"channel by users that aren't IRC operators."));
|
||||
else
|
||||
return false;
|
||||
source.Reply(_("Type \002%s%s HELP SET \037option\037\002 for more information on a\n"
|
||||
"particular option."), Config->UseStrictPrivMsgString.c_str(), source.owner->nick.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnSyntaxError(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
if (subcommand.empty())
|
||||
Command::OnSyntaxError(source, "");
|
||||
else if (subcommand.equals_ci("PRIVATE"))
|
||||
this->SendSyntax(source, "\037botname\037 PRIVATE {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("DONTKICKOPS"))
|
||||
this->SendSyntax(source, "\037channel\037 DONTKICKOPS {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("DONTKICKVOICES"))
|
||||
this->SendSyntax(source, "\037channel\037 DONTKICKVOICES {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("FANTASY"))
|
||||
this->SendSyntax(source, "\037channel\037 FANTASY {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("GREET"))
|
||||
this->SendSyntax(source, "\037channel\037 GREET {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("NOBOT"))
|
||||
this->SendSyntax(source, "\037channel\037 NOBOT {\037ON|OFF\037}");
|
||||
else
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
};
|
||||
|
||||
class BSSet : public Module
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
class CommandBSSetDontKickOps : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetDontKickOps(Module *creator, const Anope::string &sname = "botserv/set/dontkickops") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("To protect ops against bot kicks"));
|
||||
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (params[1].equals_ci("ON"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable dontkickops";
|
||||
|
||||
ci->botflags.SetFlag(BS_DONTKICKOPS);
|
||||
source.Reply(_("Bot \002won't kick ops\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (params[1].equals_ci("OFF"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable dontkickops";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_DONTKICKOPS);
|
||||
source.Reply(_("Bot \002will kick ops\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"Enables or disables \002ops protection\002 mode on a channel.\n"
|
||||
"When it is enabled, ops won't be kicked by the bot\n"
|
||||
"even if they don't match the NOKICK level."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetDontKickOps : public Module
|
||||
{
|
||||
CommandBSSetDontKickOps commandbssetdontkickops;
|
||||
|
||||
public:
|
||||
BSSetDontKickOps(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetdontkickops(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetDontKickOps)
|
||||
@@ -0,0 +1,90 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
class CommandBSSetDontKickVoices : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetDontKickVoices(Module *creator, const Anope::string &sname = "botserv/set/dontkickvoices") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("To protect voices against bot kicks"));
|
||||
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (params[1].equals_ci("ON"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable dontkickvoices";
|
||||
|
||||
ci->botflags.SetFlag(BS_DONTKICKVOICES);
|
||||
source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (params[1].equals_ci("OFF"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable dontkickvoices";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_DONTKICKVOICES);
|
||||
source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"Enables or disables \002voices protection\002 mode on a channel.\n"
|
||||
"When it is enabled, voices won't be kicked by the bot\n"
|
||||
"even if they don't match the NOKICK level."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetDontKickVoices : public Module
|
||||
{
|
||||
CommandBSSetDontKickVoices commandbssetdontkickvoices;
|
||||
|
||||
public:
|
||||
BSSetDontKickVoices(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetdontkickvoices(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetDontKickVoices)
|
||||
@@ -0,0 +1,100 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
class CommandBSSetFantasy : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetFantasy(Module *creator, const Anope::string &sname = "botserv/set/fantasy") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("Enable fantaisist commands"));
|
||||
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
const Anope::string &value = params[1];
|
||||
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable fantasy";
|
||||
|
||||
ci->botflags.SetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable fantasy";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"Enables or disables \002fantasy\002 mode on a channel.\n"
|
||||
"When it is enabled, users will be able to use\n"
|
||||
"%s commands on a channel when prefixed\n"
|
||||
"with one of the following fantasy characters: \002%s\002\n"
|
||||
" \n"
|
||||
"Note that users wanting to use fantaisist\n"
|
||||
"commands MUST have enough level for both\n"
|
||||
"the FANTASIA and another level depending\n"
|
||||
"of the command if required (for example, to use \n"
|
||||
"!op, user must have enough access for the OPDEOP\n"
|
||||
"level)."), Config->ChanServ.c_str(), Config->BSFantasyCharacter.c_str());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetFantasy : public Module
|
||||
{
|
||||
CommandBSSetFantasy commandbssetfantasy;
|
||||
|
||||
public:
|
||||
BSSetFantasy(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetfantasy(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetFantasy)
|
||||
@@ -0,0 +1,93 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
class CommandBSSetGreet : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetGreet(Module *creator, const Anope::string &sname = "botserv/set/greet") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("Enable greet messages"));
|
||||
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
const Anope::string &value = params[1];
|
||||
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable greets";
|
||||
|
||||
ci->botflags.SetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable greets";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"Enables or disables \002greet\002 mode on a channel.\n"
|
||||
"When it is enabled, the bot will display greet\n"
|
||||
"messages of users joining the channel, provided\n"
|
||||
"they have enough access to the channel."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetGreet : public Module
|
||||
{
|
||||
CommandBSSetGreet commandbssetgreet;
|
||||
|
||||
public:
|
||||
BSSetGreet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetgreet(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetGreet)
|
||||
@@ -0,0 +1,88 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
class CommandBSSetNoBot : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetNoBot(Module *creator, const Anope::string &sname = "botserv/set/nobot") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("Prevent a bot from being assigned to a channel"));
|
||||
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
const Anope::string &value = params[1];
|
||||
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!u->HasCommand("botserv/set/nobot"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to enable nobot";
|
||||
|
||||
ci->botflags.SetFlag(BS_NOBOT);
|
||||
if (ci->bi)
|
||||
ci->bi->UnAssign(u, ci);
|
||||
source.Reply(_("No Bot mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to disable nobot";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_NOBOT);
|
||||
source.Reply(_("No Bot mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"This option makes a channel be unassignable. If a bot \n"
|
||||
"is already assigned to the channel, it is unassigned\n"
|
||||
"automatically when you enable the option."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetNoBot : public Module
|
||||
{
|
||||
CommandBSSetNoBot commandbssetnobot;
|
||||
|
||||
public:
|
||||
BSSetNoBot(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetnobot(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetNoBot)
|
||||
@@ -0,0 +1,79 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
class CommandBSSetPrivate : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetPrivate(Module *creator, const Anope::string &sname = "botserv/set/private") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("Prevent a bot from being assigned by non IRC operators"));
|
||||
this->SetSyntax(_("\037botname\037 {\037ON|OFF\037}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
BotInfo *bi = findbot(params[0]);
|
||||
const Anope::string &value = params[1];
|
||||
|
||||
if (bi == NULL)
|
||||
{
|
||||
source.Reply(BOT_DOES_NOT_EXIST, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!u->HasCommand("botserv/set/private"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bi->SetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002on\002."), bi->nick.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bi->UnsetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002off\002."), bi->nick.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"This option prevents a bot from being assigned to a\n"
|
||||
"channel by users that aren't IRC operators."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetPrivate : public Module
|
||||
{
|
||||
CommandBSSetPrivate commandbssetprivate;
|
||||
|
||||
public:
|
||||
BSSetPrivate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetprivate(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetPrivate)
|
||||
Reference in New Issue
Block a user