mirror of
https://github.com/anope/anope.git
synced 2026-07-09 15:43:13 +02:00
Add botserv bot usermode config option
This commit is contained in:
@@ -112,6 +112,12 @@ module
|
||||
* This directive is optional.
|
||||
*/
|
||||
botmodes = "ao"
|
||||
|
||||
/*
|
||||
* User modes to set on service bots. Read the comment about the service:modes directive
|
||||
* on why this can be a bad idea to set.
|
||||
*/
|
||||
#botumodes = "i"
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -415,6 +415,11 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { }
|
||||
|
||||
/** Called when a bot is created or destroyed
|
||||
*/
|
||||
virtual void OnCreateBot(BotInfo *bi) { }
|
||||
virtual void OnDelBot(BotInfo *bi) { }
|
||||
|
||||
/** Called before a bot kicks a user
|
||||
* @param bi The bot sending the kick
|
||||
* @param c The channel the user is being kicked on
|
||||
@@ -1040,6 +1045,7 @@ enum Implementation
|
||||
I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnSetChannelOption, I_OnChannelSync, I_OnSetCorrectModes,
|
||||
|
||||
/* BotServ */
|
||||
I_OnCreateBot, I_OnDelBot,
|
||||
I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnPreBotAssign, I_OnBotAssign, I_OnBotUnAssign,
|
||||
I_OnPreUserKicked, I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBadWordAdd, I_OnBadWordDel,
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class BotServCore : public Module
|
||||
BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR)
|
||||
{
|
||||
Implementation i[] = { I_OnReload, I_OnSetCorrectModes, I_OnBotAssign, I_OnBotDelete, I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel,
|
||||
I_OnPreHelp, I_OnPostHelp, I_OnChannelModeSet, I_OnCreateChan, I_OnUserKicked };
|
||||
I_OnPreHelp, I_OnPostHelp, I_OnChannelModeSet, I_OnCreateChan, I_OnUserKicked, I_OnCreateBot };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
}
|
||||
|
||||
@@ -347,6 +347,12 @@ class BotServCore : public Module
|
||||
/* Bots get rejoined */
|
||||
bi->Join(channel, &status);
|
||||
}
|
||||
|
||||
void OnCreateBot(BotInfo *bi) anope_override
|
||||
{
|
||||
if (bi->botmodes.empty())
|
||||
bi->botmodes = Config->GetModule(this)->Get<const Anope::string>("botumodes");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BotServCore)
|
||||
|
||||
@@ -32,6 +32,8 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
|
||||
(*BotListByNick)[this->nick] = this;
|
||||
if (!this->uid.empty())
|
||||
(*BotListByUID)[this->uid] = this;
|
||||
|
||||
FOREACH_MOD(I_OnCreateBot, OnCreateBot(this));
|
||||
|
||||
// If we're synchronised with the uplink already, send the bot.
|
||||
if (Me && Me->IsSynced())
|
||||
@@ -49,6 +51,8 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
|
||||
|
||||
BotInfo::~BotInfo()
|
||||
{
|
||||
FOREACH_MOD(I_OnDelBot, OnDelBot(this));
|
||||
|
||||
// If we're synchronised with the uplink already, send the bot.
|
||||
if (Me && Me->IsSynced())
|
||||
{
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
|
||||
if (sserver && sserver->IsSynced()) // Our bots are introduced on startup with no server
|
||||
{
|
||||
++sserver->users;
|
||||
Log(this, "connect") << (!svhost.empty() ? Anope::string("(") + svhost + ") " : "") << "(" << srealname << ") " << sip << " connected to the network (" << sserver->GetName() << ")";
|
||||
Log(this, "connect") << (!vhost.empty() && vhost != host ? "(" + vhost + ") " : "") << "(" << srealname << ") " << (!sip.empty() && sip != host ? "[" + sip + "] " : "") << "connected to the network (" << sserver->GetName() << ")";
|
||||
}
|
||||
|
||||
if (UserListByNick.size() > MaxUserCount)
|
||||
@@ -622,7 +622,7 @@ void User::SetModesInternal(const char *umodes, ...)
|
||||
vsnprintf(buf, BUFSIZE - 1, umodes, args);
|
||||
va_end(args);
|
||||
|
||||
if (this->server && this->server->IsSynced())
|
||||
if (this->server && this->server->IsSynced() && Anope::string(buf) != "+")
|
||||
Log(this, "mode") << "changes modes to " << buf;
|
||||
|
||||
spacesepstream sep(buf);
|
||||
|
||||
Reference in New Issue
Block a user