1
0
mirror of https://github.com/anope/anope.git synced 2026-07-07 12:03:12 +02:00

Allow bot usermodes to be configurable

This commit is contained in:
Adam
2011-08-12 03:13:56 -04:00
parent 54710a782b
commit feee50e695
24 changed files with 150 additions and 31 deletions
+13
View File
@@ -26,6 +26,19 @@ service
* The realname of the BotServ client.
*/
gecos = "Bot Service"
/*
* The modes this client should use.
* Do not modify this unless you know what you are doing.
*
* These modes are very IRCd specific. If left commented, sane defaults
* are used based on what protocol module you have loaded.
*
* Note that setting this option incorrectly could potentially BREAK some if
* not all usefulness of the client. We will not support you if this client is
* unable to do certain things if this option is enabled.
*/
#modes = "+o"
}
/*
+13
View File
@@ -26,6 +26,19 @@ service
* The realname of the ChanServ client.
*/
gecos = "Channel Registration Service"
/*
* The modes this client should use.
* Do not modify this unless you know what you are doing.
*
* These modes are very IRCd specific. If left commented, sane defaults
* are used based on what protocol module you have loaded.
*
* Note that setting this option incorrectly could potentially BREAK some if
* not all usefulness of the client. We will not support you if this client is
* unable to do certain things if this option is enabled.
*/
#modes = "+o"
}
/*
+13
View File
@@ -26,6 +26,19 @@ service
* The realname of the Global client.
*/
gecos = "Global Noticer"
/*
* The modes this client should use.
* Do not modify this unless you know what you are doing.
*
* These modes are very IRCd specific. If left commented, sane defaults
* are used based on what protocol module you have loaded.
*
* Note that setting this option incorrectly could potentially BREAK some if
* not all usefulness of the client. We will not support you if this client is
* unable to do certain things if this option is enabled.
*/
#modes = "+o"
}
/*
+13
View File
@@ -26,6 +26,19 @@ service
* The realname of the HostServ client.
*/
gecos = "vHost Service"
/*
* The modes this client should use.
* Do not modify this unless you know what you are doing.
*
* These modes are very IRCd specific. If left commented, sane defaults
* are used based on what protocol module you have loaded.
*
* Note that setting this option incorrectly could potentially BREAK some if
* not all usefulness of the client. We will not support you if this client is
* unable to do certain things if this option is enabled.
*/
#modes = "+o"
}
/*
+13
View File
@@ -26,6 +26,19 @@ service
* The realname of the MemoServ client.
*/
gecos = "Memo Service"
/*
* The modes this client should use.
* Do not modify this unless you know what you are doing.
*
* These modes are very IRCd specific. If left commented, sane defaults
* are used based on what protocol module you have loaded.
*
* Note that setting this option incorrectly could potentially BREAK some if
* not all usefulness of the client. We will not support you if this client is
* unable to do certain things if this option is enabled.
*/
#modes = "+o"
}
/*
+13
View File
@@ -26,6 +26,19 @@ service
* The realname of the NickServ client.
*/
gecos = "Nickname Registration Service"
/*
* The modes this client should use.
* Do not modify this unless you know what you are doing.
*
* These modes are very IRCd specific. If left commented, sane defaults
* are used based on what protocol module you have loaded.
*
* Note that setting this option incorrectly could potentially BREAK some if
* not all usefulness of the client. We will not support you if this client is
* unable to do certain things if this option is enabled.
*/
#modes = "+o"
}
/*
+13
View File
@@ -26,6 +26,19 @@ service
* The realname of the OperServ client.
*/
gecos = "Operator Service"
/*
* The modes this client should use.
* Do not modify this unless you know what you are doing.
*
* These modes are very IRCd specific. If left commented, sane defaults
* are used based on what protocol module you have loaded.
*
* Note that setting this option incorrectly could potentially BREAK some if
* not all usefulness of the client. We will not support you if this client is
* unable to do certain things if this option is enabled.
*/
#modes = "+o"
}
/*
+2 -2
View File
@@ -11,8 +11,7 @@ Legend:
[x] Rewrite commands system
[x] Rewrite access system
[x] NS INFO: separate field for last seen realhost, shown to SRA only
[ ] Customize email messages
[ ] Configurable bot usermodes
[x] Configurable bot usermodes
Future
@@ -34,3 +33,4 @@ Future
[ ] HS ACTIVATE -ALL (rob sez this all needs reviewing)
[ ] No nickname ownership?
[ ] More commands need to be split up such as /bs bot, /ms set, /bs kick, /bs set, /os set? etc.
[ ] Customize email messages
+2 -1
View File
@@ -40,6 +40,7 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
time_t lastmsg; /* Last time we said something */
typedef Anope::insensitive_map<CommandInfo> command_map;
command_map commands; /* Commands, actual name to service name */
Anope::string botmodes; /* Modes the bot should have as configured in service:modes */
/** Create a new bot.
* @param nick The nickname to assign to the bot.
@@ -47,7 +48,7 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
* @param host The hostname to give the bot.
* @param real The realname to give the bot.
*/
BotInfo(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "");
BotInfo(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "", const Anope::string &modes = "");
/** Destroy a bot, clearing up appropriately.
*/
+1 -1
View File
@@ -800,7 +800,7 @@ class CoreExport IRCDProto
virtual void SendSVSKill(const BotInfo *source, const User *user, const char *fmt, ...);
virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...);
virtual void SendClientIntroduction(const User *u, const Anope::string &) = 0;
virtual void SendClientIntroduction(const User *u) = 0;
virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...);
virtual void SendNoticeChanops(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
virtual void SendMessage(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
+5
View File
@@ -271,6 +271,11 @@ class CoreExport User : public Extensible
*/
void SetModesInternal(const char *umodes, ...);
/** Get modes set for this user.
* @return A string of modes set on the user
*/
Anope::string GetModes() const;
/** Find the channel container for Channel c that the user is on
* This is preferred over using FindUser in Channel, as there are usually more users in a channel
* than channels a user is in
+1 -1
View File
@@ -249,7 +249,7 @@ class CommandBSBot : public Command
if (!user.empty())
{
ircdproto->SendClientIntroduction(bi, ircd->pseudoclient_mode);
ircdproto->SendClientIntroduction(bi);
bi->RejoinAll();
}
+2 -3
View File
@@ -214,10 +214,9 @@ class BahamutIRCdProto : public IRCDProto
send_cmd(source->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
}
void SendClientIntroduction(const User *u, const Anope::string &modes)
void SendClientIntroduction(const User *u)
{
XLine x(u->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
Anope::string modes = "+" + u->GetModes();
send_cmd("", "NICK %s 1 %ld %s %s %s %s 0 0 :%s", u->nick.c_str(), static_cast<long>(u->timestamp), modes.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->server->GetName().c_str(), u->realname.c_str());
}
+2 -1
View File
@@ -103,8 +103,9 @@ class InspIRCdTS6Proto : public IRCDProto
send_cmd(bi ? bi->GetUID() : Config->Numeric, "MODE %s %s", u->GetUID().c_str(), buf.c_str());
}
void SendClientIntroduction(const User *u, const Anope::string &modes)
void SendClientIntroduction(const User *u)
{
Anope::string modes = "+" + u->GetModes();
send_cmd(Config->Numeric, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", u->GetUID().c_str(), static_cast<long>(u->timestamp), u->nick.c_str(), u->host.c_str(), u->host.c_str(), u->GetIdent().c_str(), static_cast<long>(u->my_signon), modes.c_str(), u->realname.c_str());
}
+2 -1
View File
@@ -135,8 +135,9 @@ class InspIRCdProto : public IRCDProto
send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str());
}
void SendClientIntroduction(const User *u, const Anope::string &modes)
void SendClientIntroduction(const User *u)
{
Anope::string modes = "+" + u->GetModes();
send_cmd(Config->ServerName, "NICK %ld %s %s %s %s %s 0.0.0.0 :%s", static_cast<long>(u->timestamp), u->nick.c_str(), u->host.c_str(), u->host.c_str(), u->GetIdent().c_str(), modes.c_str(), u->realname.c_str());
send_cmd(u->nick, "OPERTYPE Service");
}
+2 -3
View File
@@ -168,10 +168,9 @@ class PlexusProto : public IRCDProto
plexus_cmd_svinfo();
}
void SendClientIntroduction(const User *u, const Anope::string &modes)
void SendClientIntroduction(const User *u)
{
XLine x(u->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
Anope::string modes = "+" + u->GetModes();
send_cmd(Config->Numeric, "UID %s 1 %ld %s %s %s 255.255.255.255 %s 0 %s :%s", u->nick.c_str(), static_cast<long>(u->timestamp), modes.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->GetUID().c_str(), u->host.c_str(), u->realname.c_str());
}
+2 -3
View File
@@ -168,10 +168,9 @@ class RatboxProto : public IRCDProto
ratbox_cmd_svinfo();
}
void SendClientIntroduction(const User *u, const Anope::string &modes)
void SendClientIntroduction(const User *u)
{
XLine x(u->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
Anope::string modes = "+" + u->GetModes();
send_cmd(Config->Numeric, "UID %s 1 %ld %s %s %s 0 %s :%s", u->nick.c_str(), static_cast<long>(u->timestamp), modes.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->GetUID().c_str(), u->realname.c_str());
}
+3 -4
View File
@@ -140,11 +140,10 @@ class UnrealIRCdProto : public IRCDProto
send_cmd(bi ? bi->nick : Config->ServerName, "v %s %s", u->nick.c_str(), buf.c_str());
}
void SendClientIntroduction(const User *u, const Anope::string &modes)
void SendClientIntroduction(const User *u)
{
XLine x(u->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
send_cmd("", "& %s 1 %ld %s %s %s 0 %s %s * :%s", u->nick.c_str(), static_cast<long>(u->timestamp), u->GetIdent().c_str(), u->host.c_str(), Config->ServerName.c_str(), modes.c_str(), u->host.c_str(), u->realname.c_str());
Anope::string modes = "+" + u->GetModes();
send_cmd("", "& %s 1 %ld %s %s %s 0 %s %s * :%s", u->nick.c_str(), static_cast<long>(u->timestamp), u->GetIdent().c_str(), u->host.c_str(), u->server->GetName().c_str(), modes.c_str(), u->host.c_str(), u->realname.c_str());
}
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf)
+5 -4
View File
@@ -13,7 +13,7 @@
Anope::insensitive_map<BotInfo *> BotListByNick;
Anope::map<BotInfo *> BotListByUID;
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal) : User(nnick, nuser, nhost, ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString)
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &modes) : User(nnick, nuser, nhost, ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), botmodes(modes)
{
this->realname = nreal;
this->server = Me;
@@ -28,13 +28,14 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
// If we're synchronised with the uplink already, send the bot.
if (Me && Me->IsSynced())
{
ircdproto->SendClientIntroduction(this, ircd->pseudoclient_mode);
ircdproto->SendClientIntroduction(this);
XLine x(this->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
}
this->SetModeInternal(ModeManager::FindUserModeByName(UMODE_PROTECTED));
this->SetModeInternal(ModeManager::FindUserModeByName(UMODE_GOD));
Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : (ircd ? ircd->pseudoclient_mode : "");
if (!tmodes.empty())
this->SetModesInternal(tmodes.c_str());
if (Config)
for (unsigned i = 0; i < Config->LogInfos.size(); ++i)
+5 -4
View File
@@ -937,6 +937,7 @@ static bool DoServices(ServerConfig *config, const Anope::string &, const Anope:
Anope::string user = values[1].GetValue();
Anope::string host = values[2].GetValue();
Anope::string gecos = values[3].GetValue();
Anope::string modes = values[4].GetValue();
ValueItem vi(nick);
if (!ValidateNotEmpty(config, "service", "nick", vi))
@@ -958,7 +959,7 @@ static bool DoServices(ServerConfig *config, const Anope::string &, const Anope:
BotInfo *bi = findbot(nick);
if (bi != NULL)
return true;
bi = new BotInfo(nick, user, host, gecos);
bi = new BotInfo(nick, user, host, gecos, modes);
bi->SetFlag(BI_CONF);
return true;
}
@@ -1257,9 +1258,9 @@ ConfigItems::ConfigItems(ServerConfig *conf)
{DT_STRING, DT_STRING, DT_STRING, DT_STRING},
InitOpers, DoOper, DoneOpers},
{"service",
{"nick", "user", "host", "gecos", ""},
{"", "", "", "", ""},
{DT_STRING, DT_STRING, DT_STRING, DT_STRING},
{"nick", "user", "host", "gecos", "modes", ""},
{"", "", "", "", "", ""},
{DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING},
InitServices, DoServices, DoneServices},
{"log",
{"target", "source", "logage", "inhabitlogchannel", "admin", "override", "commands", "servers", "channels", "users", "other", "rawio", "debug", ""},
+1 -1
View File
@@ -27,7 +27,7 @@ void introduce_user(const Anope::string &user)
User *u = finduser(user);
if (u)
{
ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
ircdproto->SendClientIntroduction(u);
BotInfo *bi = findbot(u->nick);
if (bi)
+1 -1
View File
@@ -60,7 +60,7 @@ NickServRelease::NickServRelease(NickAlias *na, time_t delay) : User(na->nick, C
NickServReleases.insert(std::make_pair(this->nick, this));
ircdproto->SendClientIntroduction(this, "+");
ircdproto->SendClientIntroduction(this);
}
NickServRelease::~NickServRelease()
+7 -1
View File
@@ -55,6 +55,12 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A
/* Load MLock from the database now that we know what modes exist */
for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
it->second->LoadMLock();
for (botinfo_map::iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
{
BotInfo *bi = it->second;
Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : ircd->pseudoclient_mode;
bi->SetModesInternal(modes.c_str());
}
ircdproto->SendBOB();
@@ -71,7 +77,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A
{
User *u = it->second;
ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
ircdproto->SendClientIntroduction(u);
BotInfo *bi = findbot(u->nick);
if (bi)
+16
View File
@@ -705,6 +705,22 @@ void User::SetModesInternal(const char *umodes, ...)
}
}
Anope::string User::GetModes() const
{
Anope::string ret;
for (size_t i = UMODE_BEGIN + 1; i < UMODE_END; ++i)
if (this->modes.HasFlag(static_cast<UserModeName>(i)))
{
UserMode *um = ModeManager::FindUserModeByName(static_cast<UserModeName>(i));
if (um == NULL)
continue;
ret += um->ModeChar;
}
return ret;
}
/** Find the channel container for Channel c that the user is on
* This is preferred over using FindUser in Channel, as there are usually more users in a channel
* than channels a user is in