summaryrefslogtreecommitdiff
path: root/src/map/channel.c
diff options
context:
space:
mode:
authorhemagx <hemagx2@gmail.com>2016-04-23 21:37:16 +0200
committerhemagx <hemagx2@gmail.com>2016-04-25 00:23:34 +0200
commit5edc982e3e2e0c6fc643b229d1c06ea75a618d15 (patch)
tree8b4129fef971fc40152a47ee412df66b0d3e1d4c /src/map/channel.c
parent31e27a130676e3e416b583bb947f9dd87efdce81 (diff)
downloadhercules-5edc982e3e2e0c6fc643b229d1c06ea75a618d15.tar.gz
hercules-5edc982e3e2e0c6fc643b229d1c06ea75a618d15.tar.bz2
hercules-5edc982e3e2e0c6fc643b229d1c06ea75a618d15.tar.xz
hercules-5edc982e3e2e0c6fc643b229d1c06ea75a618d15.zip
Added a flood protection to IRC Bot
Now it's possible to send as many messages as possible without get kicked for flood.
Diffstat (limited to 'src/map/channel.c')
-rw-r--r--src/map/channel.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/map/channel.c b/src/map/channel.c
index e4e3d069d..f36388bca 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -609,7 +609,10 @@ void read_channels_config(void)
local_autojoin = 0, ally_autojoin = 0,
allow_user_channel_creation = 0,
irc_enabled = 0,
- irc_autojoin = 0;
+ irc_autojoin = 0,
+ irc_flood_protection_rate = 0,
+ irc_flood_protection_burst = 0,
+ irc_flood_protection_enabled = 0;
if( !libconfig->setting_lookup_string(settings, "map_local_channel_name", &local_name) )
local_name = "map";
@@ -686,7 +689,6 @@ void read_channels_config(void)
libconfig->setting_lookup_bool(settings, "map_local_channel_autojoin", &local_autojoin);
libconfig->setting_lookup_bool(settings, "ally_channel_autojoin", &ally_autojoin);
libconfig->setting_lookup_bool(settings, "irc_channel_autojoin", &irc_autojoin);
-
if (local_autojoin)
channel->config->local_autojoin = true;
if (ally_autojoin)
@@ -694,6 +696,26 @@ void read_channels_config(void)
if (irc_autojoin)
channel->config->irc_autojoin = true;
+ libconfig->setting_lookup_int(settings, "irc_flood_protection_burst", &irc_flood_protection_burst);
+
+ if (irc_flood_protection_enabled) {
+ ircbot->flood_protection_enabled = true;
+
+ libconfig->setting_lookup_bool(settings, "irc_flood_protection_enabled", &irc_flood_protection_enabled);
+ libconfig->setting_lookup_int(settings, "irc_flood_protection_rate", &irc_flood_protection_rate);
+
+ if (irc_flood_protection_rate > 0)
+ ircbot->flood_protection_rate = irc_flood_protection_rate;
+ else
+ ircbot->flood_protection_rate = 1000;
+ if (irc_flood_protection_burst > 0)
+ ircbot->flood_protection_burst = irc_flood_protection_burst;
+ else
+ ircbot->flood_protection_burst = 3;
+ } else {
+ ircbot->flood_protection_enabled = false;
+ }
+
libconfig->setting_lookup_bool(settings, "allow_user_channel_creation", &allow_user_channel_creation);
if( allow_user_channel_creation )