1 /* bot_NeonSpam.h - NeonServ v5.4
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
21 #include "../../main.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_BADWORDSCAN 0x080000
74 #define SPAMSETTINGS_BADWORDSCAN_OPS 0x100000
75 #define SPAMSETTINGS_BADWORDSCAN_VOICE 0x200000
76 #define SPAMSETTINGS_BADWORDCHARS "tuv"
77 #define SPAMSETTINGS_BADWORDEXCINDEX 6
79 #define SPAMSETTINGS_CHARS SPAMSETTINGS_SPAMCHARS SPAMSETTINGS_FLOODCHARS SPAMSETTINGS_JOINCHARS SPAMSETTINGS_BOTNETCHARS SPAMSETTINGS_CAPSCHARS SPAMSETTINGS_DIGITCHARS SPAMSETTINGS_BADWORDCHARS
80 #define SPAMSETTINGS_FLAGS 0x7fffff /* all flags that can be stored in the database */
81 #define SPAMSETTINGS_EXCEPTINDEXES 7
82 #define SPAMSETTINGS_SENSIBILITYINDEXES 2
83 #define SPAMSETTINGS_PERCENTINDEXES 2
86 #define SPAMSETTINGS_KICKEDBOTQUEUE 0x0400000
87 #define SPAMSETTINGS_ISTIMEBAN 0x0800000
88 #define SPAMSETTINGS_SETTIMEBAN 0x1000000
90 #define MAX_FLOOD_AMOUNT 300
91 #define MIN_FLOOD_AMOUNT 2
92 #define MAX_FLOOD_TIME 200
94 #define MAX_JOIN_AMOUNT 300
95 #define MIN_JOIN_AMOUNT 2
96 #define MAX_JOIN_TIME 200
98 #define BOTNETSCAN_USERS 4
99 #define BOTNETSCAN_TIME 2
101 struct NeonSpamSettings {
103 unsigned char spam_amount;
104 unsigned char sensibility_amount[SPAMSETTINGS_SENSIBILITYINDEXES];
105 unsigned char sensibility_time[SPAMSETTINGS_SENSIBILITYINDEXES];
106 unsigned int exceptlevel[SPAMSETTINGS_EXCEPTINDEXES];
107 unsigned char percent[SPAMSETTINGS_PERCENTINDEXES];
110 struct NeonSpamJoinNode *join_nodes;
113 unsigned long lastmsg; //crc32 hash
115 char *botnicks[BOTNETSCAN_USERS];
118 struct NeonSpamBadword *badwords;
121 struct NeonSpamBadword {
124 unsigned char use_defaults : 1;
125 unsigned int exceptlevel : 9;
126 unsigned char scan_ops : 1;
127 unsigned char scan_voice : 1;
128 unsigned char use_default_reaction : 1;
129 unsigned int reaction;
130 unsigned int reaction_time;
131 struct NeonSpamBadword *next;
135 * user gets MAX_FLOOD_TIME points per message
136 * points get removed each loop
137 * pounts to be removed each second:
138 * MAX_FLOOD_TIME/flood_time
140 * the floodlimit is reached, if the penalty points
141 * are bigger than MAX_FLOOD_TIME * flood_amount
144 #define NEONSPAMNODE_FLAG_CAPSSCAN_WARNED 0x01
145 #define NEONSPAMNODE_FLAG_DIGITSCAN_WARNED 0x02
147 struct NeonSpamNode {
148 unsigned long lastmsg; //crc32 hash
149 unsigned char spamcount;
151 time_t last_penalty_update;
155 struct NeonSpamJoinNode {
159 time_t last_penalty_update;
160 struct NeonSpamJoinNode *next;
163 void init_NeonSpam(int type);
164 void loop_NeonSpam();
165 void free_NeonSpam(int type);
167 void freeNeonSpamSettings(struct NeonSpamSettings *settings);
168 char* convertNeonSpamSettingsToString(unsigned int flags, char *buffer);
169 int loadNeonSpamSettings(struct ChanNode *chan);