1 /* bot_NeonSpam.h - NeonServ v5.3
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef _bot_NeonSpam_h
19 #define _bot_NeonSpam_h
26 #define SPAMSETTINGS_SPAMSCAN 0x000001
27 #define SPAMSETTINGS_SPAMSCAN_OPS 0x000002
28 #define SPAMSETTINGS_SPAMSCAN_VOICE 0x000004
29 #define SPAMSETTINGS_SPAMCHARS "abc"
30 #define SPAMSETTINGS_SPAMEXCINDEX 0
33 #define SPAMSETTINGS_FLOODSCAN 0x000008
34 #define SPAMSETTINGS_FLOODSCAN_OPS 0x000010
35 #define SPAMSETTINGS_FLOODSCAN_VOICE 0x000020
36 #define SPAMSETTINGS_FLOODCHARS "def"
37 #define SPAMSETTINGS_FLOODEXCINDEX 1
38 #define SPAMSETTINGS_FLOODSENINDEX 0
41 #define SPAMSETTINGS_JOINSCAN 0x000040
42 #define SPAMSETTINGS_JOINSCAN_OPS 0x000080
43 #define SPAMSETTINGS_JOINSCAN_VOICE 0x000100
44 #define SPAMSETTINGS_JOINCHARS "ghi"
45 #define SPAMSETTINGS_JOINEXCINDEX 2
46 #define SPAMSETTINGS_JOINSENINDEX 1
49 #define SPAMSETTINGS_BOTNETSCAN 0x000200
50 #define SPAMSETTINGS_BOTNETSCAN_OPS 0x000400
51 #define SPAMSETTINGS_BOTNETSCAN_VOICE 0x000800
52 #define SPAMSETTINGS_BOTNETSCAN_STRIPCC 0x001000
53 #define SPAMSETTINGS_BOTNETCHARS "jklm"
54 #define SPAMSETTINGS_BOTNETEXCINDEX 3
57 #define SPAMSETTINGS_CAPSSCAN 0x002000
58 #define SPAMSETTINGS_CAPSSCAN_OPS 0x004000
59 #define SPAMSETTINGS_CAPSSCAN_VOICE 0x008000
60 #define SPAMSETTINGS_CAPSCHARS "nop"
61 #define SPAMSETTINGS_CAPSEXCINDEX 4
62 #define SPAMSETTINGS_CAPSPERCENTINDEX 0
65 #define SPAMSETTINGS_DIGITSCAN 0x010000
66 #define SPAMSETTINGS_DIGITSCAN_OPS 0x020000
67 #define SPAMSETTINGS_DIGITSCAN_VOICE 0x040000
68 #define SPAMSETTINGS_DIGITCHARS "qrs"
69 #define SPAMSETTINGS_DIGITEXCINDEX 5
70 #define SPAMSETTINGS_DIGITPERCENTINDEX 1
73 #define SPAMSETTINGS_CHARS SPAMSETTINGS_SPAMCHARS SPAMSETTINGS_FLOODCHARS SPAMSETTINGS_JOINCHARS SPAMSETTINGS_BOTNETCHARS SPAMSETTINGS_CAPSCHARS SPAMSETTINGS_DIGITCHARS
74 #define SPAMSETTINGS_FLAGS 0x07ffff /* all flags that can be stored in the database */
75 #define SPAMSETTINGS_EXCEPTINDEXES 6
76 #define SPAMSETTINGS_SENSIBILITYINDEXES 2
77 #define SPAMSETTINGS_PERCENTINDEXES 2
80 #define SPAMSETTINGS_KICKEDBOTQUEUE 0x080000
81 #define SPAMSETTINGS_ISTIMEBAN 0x100000
82 #define SPAMSETTINGS_SETTIMEBAN 0x200000
84 #define MAX_FLOOD_AMOUNT 300
85 #define MIN_FLOOD_AMOUNT 2
86 #define MAX_FLOOD_TIME 200
88 #define MAX_JOIN_AMOUNT 300
89 #define MIN_JOIN_AMOUNT 2
90 #define MAX_JOIN_TIME 200
92 #define BOTNETSCAN_USERS 4
93 #define BOTNETSCAN_TIME 2
95 struct NeonSpamSettings {
97 unsigned char spam_amount;
98 unsigned char sensibility_amount[SPAMSETTINGS_SENSIBILITYINDEXES];
99 unsigned char sensibility_time[SPAMSETTINGS_SENSIBILITYINDEXES];
100 unsigned int exceptlevel[SPAMSETTINGS_EXCEPTINDEXES];
101 unsigned char percent[SPAMSETTINGS_PERCENTINDEXES];
104 struct NeonSpamJoinNode *join_nodes;
107 unsigned long lastmsg; //crc32 hash
109 char *botnicks[BOTNETSCAN_USERS];
114 * user gets MAX_FLOOD_TIME points per message
115 * points get removed each loop
116 * pounts to be removed each second:
117 * MAX_FLOOD_TIME/flood_time
119 * the floodlimit is reached, if the penalty points
120 * are bigger than MAX_FLOOD_TIME * flood_amount
123 #define NEONSPAMNODE_FLAG_CAPSSCAN_WARNED 0x01
124 #define NEONSPAMNODE_FLAG_DIGITSCAN_WARNED 0x02
126 struct NeonSpamNode {
127 unsigned long lastmsg; //crc32 hash
128 unsigned char spamcount;
130 time_t last_penalty_update;
134 struct NeonSpamJoinNode {
138 time_t last_penalty_update;
139 struct NeonSpamJoinNode *next;
142 void init_NeonSpam(int type);
143 void loop_NeonSpam();
144 void free_NeonSpam(int type);
146 void freeNeonSpamSettings(struct NeonSpamSettings *settings);
147 char* convertNeonSpamSettingsToString(unsigned int flags, char *buffer);
148 int loadNeonSpamSettings(struct ChanNode *chan);