summaryrefslogtreecommitdiff
path: root/src/map/irc-bot.h
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/irc-bot.h
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/irc-bot.h')
-rw-r--r--src/map/irc-bot.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h
index dc67e2fe8..949305bc9 100644
--- a/src/map/irc-bot.h
+++ b/src/map/irc-bot.h
@@ -39,6 +39,11 @@ struct irc_func {
void (*func)(int, char*, char*, char*, char*);
};
+struct message_flood {
+ char message[IRC_MESSAGE_LENGTH];
+ struct message_flood *next;
+};
+
struct irc_bot_interface {
int fd;
bool isIn, isOn;
@@ -46,6 +51,15 @@ struct irc_bot_interface {
unsigned char fails;
uint32 ip;
unsigned short port;
+ /* messages flood protection */
+ bool flood_protection_enabled;
+ int flood_protection_rate;
+ int flood_protection_burst;
+ int64 last_message_tick;
+ int messages_burst_count;
+ int queue_tid;
+ struct message_flood *message_current;
+ struct message_flood *message_last;
/* */
struct channel_data *channel;
/* */
@@ -67,7 +81,9 @@ struct irc_bot_interface {
int (*identify_timer) (int tid, int64 tick, int id, intptr_t data);
int (*join_timer) (int tid, int64 tick, int id, intptr_t data);
/* */
- void (*send)(char *str);
+ int (*queue_timer) (int tid, int64 tick, int id, intptr_t data);
+ void (*queue) (char *str);
+ void (*send)(char *str, bool force);
void (*relay) (const char *name, const char *msg);
/* */
void (*pong) (int fd, char *cmd, char *source, char *target, char *msg);