summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes.conf1
-rw-r--r--data/example.conf5
-rw-r--r--include/configreader.h2
-rw-r--r--include/extern.h2
-rw-r--r--src/botserv.c6
-rw-r--r--src/config.c1
-rw-r--r--src/modes.cpp15
7 files changed, 30 insertions, 2 deletions
diff --git a/Changes.conf b/Changes.conf
index 4bf6a9253..a0247129a 100644
--- a/Changes.conf
+++ b/Changes.conf
@@ -4,6 +4,7 @@ Anope Version 1.9.2
options:enablelogchannel added to auto turn on the logchannel on startup
options:mlock added to configure the default mlock modes on new channels
options:database added for the database modules
+options:botmodes added to configure modes BotServ bots should use
** MODIFIED CONFIGURATION DIRECTIVES **
options:encryption added enc_sha256
diff --git a/data/example.conf b/data/example.conf
index c409222fb..c2ba553a6 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -512,6 +512,11 @@ options
* Default modes for mode lock, these are set on newly registered channels.
*/
mlock = "+nrt"
+
+ /*
+ * Modes to set on service bots when they join channels, comment this out for no modes
+ */
+ botmodes = "ao"
}
diff --git a/include/configreader.h b/include/configreader.h
index c9db6cb89..a22736463 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -481,6 +481,8 @@ class ServerConfig
unsigned NewsCount;
/* Default mlock modes */
std::string MLock;
+ /* Default botmodes on channels, defaults to ao */
+ std::string BotModes;
/* Services can use email */
bool UseMail;
diff --git a/include/extern.h b/include/extern.h
index 21b7bdb81..6c147897a 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -355,6 +355,8 @@ E int str_is_cidr(char *str, uint32 * ip, uint32 * mask, char **host);
E std::bitset<128> DefMLockOn;
E std::bitset<128> DefMLockOff;
E std::map<ChannelModeName, std::string> DefMLockParams;
+/* Modes to set on bots when they join the channel */
+E std::list<ChannelModeStatus *> BotModes;
E void SetDefaultMLock();
/**** modules.c ****/
diff --git a/src/botserv.c b/src/botserv.c
index 74066fe9a..24321f559 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -644,8 +644,10 @@ void bot_join(ChannelInfo * ci)
ci->bi->nick.c_str(), ci->bi->nick.c_str());
}
ircdproto->SendJoin(ci->bi, ci->c->name.c_str(), ci->c->creation_time);
- ci->c->SetMode(NULL, CMODE_PROTECT, ci->bi->nick);
- ci->c->SetMode(NULL, CMODE_OP, ci->bi->nick);
+ for (std::list<ChannelModeStatus *>::iterator it = BotModes.begin(); it != BotModes.end(); ++it)
+ {
+ ci->c->SetMode(ci->bi, *it, ci->bi->nick, false);
+ }
FOREACH_MOD(I_OnBotJoin, OnBotJoin(ci, ci->bi));
}
diff --git a/src/config.c b/src/config.c
index 94fbd75af..08d29f692 100644
--- a/src/config.c
+++ b/src/config.c
@@ -640,6 +640,7 @@ int ServerConfig::Read(bool bail)
{"options", "ulineservers", "", new ValueContainerChar(&UlineServers), DT_CHARPTR, NoValidation},
{"options", "enablelogchannel", "no", new ValueContainerBool(&LogChan), DT_BOOLEAN, NoValidation},
{"options", "mlock", "+nrt", new ValueContainerString(&Config.MLock), DT_STRING, NoValidation},
+ {"options", "botmodes", "", new ValueContainerString(&Config.BotModes), DT_STRING, NoValidation},
{"nickserv", "nick", "NickServ", new ValueContainerChar(&Config.s_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty},
{"nickserv", "description", "Nickname Registration Service", new ValueContainerChar(&Config.desc_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty},
{"nickserv", "emailregistration", "no", new ValueContainerBool(&Config.NSEmailReg), DT_BOOLEAN, NoValidation},
diff --git a/src/modes.cpp b/src/modes.cpp
index dfee2b214..466d7900c 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -15,6 +15,7 @@
/* List of pairs of user/channels and their stacker info */
std::list<std::pair<void *, StackerInfo *> > ModeManager::StackerObjects;
+/* User modes */
std::map<char, UserMode *> ModeManager::UserModesByChar;
std::map<UserModeName, UserMode *> ModeManager::UserModesByName;
/* Channel modes */
@@ -31,6 +32,8 @@ std::bitset<128> DefMLockOn;
std::bitset<128> DefMLockOff;
/* Map for default mlocked mode parameters */
std::map<ChannelModeName, std::string> DefMLockParams;
+/* Modes to set on bots when they join the channel */
+std::list<ChannelModeStatus *> BotModes;
/** Parse the mode string from the config file and set the default mlocked modes
*/
@@ -77,6 +80,18 @@ void SetDefaultMLock()
}
}
}
+
+ /* Set Bot Modes */
+ BotModes.clear();
+ for (unsigned i = 0; i < Config.BotModes.size(); ++i)
+ {
+ ChannelMode *cm = ModeManager::FindChannelModeByChar(Config.BotModes[i]);
+
+ if (cm && cm->Type == MODE_STATUS && std::find(BotModes.begin(), BotModes.end(), cm) == BotModes.end())
+ {
+ BotModes.push_back(dynamic_cast<ChannelModeStatus *>(cm));
+ }
+ }
}
/** Default constructor