summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-11-13 17:06:49 +0100
committerGitHub <noreply@github.com>2018-11-13 17:06:49 +0100
commitd564cdaabdb9f1929e58cd68c1208f89100acf90 (patch)
treebf48c34155abe1b28962078c0609a99a04e741c8
parent78db115b41d966daf26160abe224701f743f6df0 (diff)
parent86b135b3e0a76680af677cca491b471d6c0d6429 (diff)
downloadhercules-d564cdaabdb9f1929e58cd68c1208f89100acf90.tar.gz
hercules-d564cdaabdb9f1929e58cd68c1208f89100acf90.tar.bz2
hercules-d564cdaabdb9f1929e58cd68c1208f89100acf90.tar.xz
hercules-d564cdaabdb9f1929e58cd68c1208f89100acf90.zip
Merge pull request #2287 from EyesOfAHawk/hcs_opt_msg_delay
Add config for '@channel setopt MessageDelay <delay>'
-rw-r--r--conf/channels.conf6
-rw-r--r--conf/messages.conf2
-rw-r--r--src/map/atcommand.c4
-rw-r--r--src/map/channel.c13
-rw-r--r--src/map/channel.h1
5 files changed, 22 insertions, 4 deletions
diff --git a/conf/channels.conf b/conf/channels.conf
index 9c2b567f4..c8f14aa27 100644
--- a/conf/channels.conf
+++ b/conf/channels.conf
@@ -64,5 +64,11 @@ chsys: (
irc_flood_protection_enabled: true /* Whether to enable anti-flood protection for outgoing messages */
irc_flood_protection_rate: 1000 /* The delay between messages during anti-flood protection (milliseconds) */
irc_flood_protection_burst: 3 /* The maximum number of messages that are sent at once burst size before triggering the anti-flood protection */
+
+ // @channel setopt MessageDelay <delay>
+ // Sets the maximum amount of message delay (in seconds) allowed for a channel.
+ // Default: 10
+ // Max: 255
+ channel_opt_msg_delay: 10
}
)
diff --git a/conf/messages.conf b/conf/messages.conf
index cf2cd15bd..2f790b13f 100644
--- a/conf/messages.conf
+++ b/conf/messages.conf
@@ -1495,7 +1495,7 @@
1448: -- Available options
1449: option '%s' is already enabled, if you'd like to disable it type '@channel opt %s 0'
1450: option '%s' is now enabled for channel '%s'
-1451: value '%d' for option '%s' is out of range (limit is 0-10)
+1451: value '%d' for option '%s' is out of range (limit is 0-%d)
1452: option '%s' is now enabled for channel '%s' with %d seconds
1453: option '%s' is now disabled for channel '%s'
1454: option '%s' is not enabled on channel '%s'
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 809a740d7..236975b32 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -9387,8 +9387,8 @@ ACMD(channel)
} else {
int v = atoi(sub3);
if (k == HCS_OPT_MSG_DELAY) {
- if (v < 0 || v > 10) {
- safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10)
+ if (v < 0 || v > channel->config->channel_opt_msg_delay) {
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1451), v, opt_str[k], channel->config->channel_opt_msg_delay);// value '%d' for option '%s' is out of range (limit is 0-%d)
clif->message(fd, atcmd_output);
return false;
}
diff --git a/src/map/channel.c b/src/map/channel.c
index eadd7367b..3ba56b100 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -624,7 +624,8 @@ static void read_channels_config(void)
irc_autojoin = 0,
irc_flood_protection_rate = 0,
irc_flood_protection_burst = 0,
- irc_flood_protection_enabled = 0;
+ irc_flood_protection_enabled = 0,
+ channel_opt_msg_delay = 10;
if( !libconfig->setting_lookup_string(settings, "map_local_channel_name", &local_name) )
local_name = "map";
@@ -820,6 +821,16 @@ static void read_channels_config(void)
}
}
+ libconfig->setting_lookup_int(settings, "channel_opt_msg_delay", &channel_opt_msg_delay);
+ if (channel_opt_msg_delay < 0) {
+ ShowWarning("channels.conf: channel_opt_msg_delay value '%d' must be from 0-255. Defaulting to 0...\n", channel_opt_msg_delay);
+ channel_opt_msg_delay = 0;
+ } else if (channel_opt_msg_delay > 255) {
+ ShowWarning("channels.conf: channel_opt_msg_delay value '%d' must be from 0-255. Defaulting to 255...\n", channel_opt_msg_delay);
+ channel_opt_msg_delay = 255;
+ }
+ channel->config->channel_opt_msg_delay = channel_opt_msg_delay;
+
ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' channels in '"CL_WHITE"%s"CL_RESET"'.\n", db_size(channel->db), config_filename);
}
libconfig->destroy(&channels_conf);
diff --git a/src/map/channel.h b/src/map/channel.h
index 4ac3c6037..c56227c66 100644
--- a/src/map/channel.h
+++ b/src/map/channel.h
@@ -75,6 +75,7 @@ struct Channel_Config {
char irc_server[40], irc_channel[50], irc_nick[40], irc_nick_pw[30];
unsigned short irc_server_port;
bool irc_use_ghost;
+ int channel_opt_msg_delay;
};
struct channel_ban_entry {