summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/botserv.example.conf6
-rw-r--r--include/modules.h6
-rw-r--r--modules/pseudoclients/botserv.cpp8
-rw-r--r--src/bots.cpp4
-rw-r--r--src/users.cpp4
5 files changed, 25 insertions, 3 deletions
diff --git a/data/botserv.example.conf b/data/botserv.example.conf
index 21dadd22c..887ddcd7d 100644
--- a/data/botserv.example.conf
+++ b/data/botserv.example.conf
@@ -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"
}
/*
diff --git a/include/modules.h b/include/modules.h
index 31b09c2cf..641f6f80e 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -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,
diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp
index 223a9787c..5a84d1e7f 100644
--- a/modules/pseudoclients/botserv.cpp
+++ b/modules/pseudoclients/botserv.cpp
@@ -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)
diff --git a/src/bots.cpp b/src/bots.cpp
index 332bd151d..37babbb5f 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -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())
{
diff --git a/src/users.cpp b/src/users.cpp
index ab8ac5777..8d0606ab1 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -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);