1 /******************************************************************************
2  *                    Internetting Cooperating Programmers
3  * ----------------------------------------------------------------------------
4  *
5  *  ____    PROJECT
6  * |  _ \  __ _ _ __   ___ ___ _ __
7  * | | | |/ _` | '_ \ / __/ _ \ '__|
8  * | |_| | (_| | | | | (_|  __/ |
9  * |____/ \__,_|_| |_|\___\___|_|   the IRC bot
10  *
11  * All files in this archive are subject to the GNU General Public License.
12  *
13  * $Source: /cvsroot/dancer/dancer/src/bans.h,v $
14  * $Revision: 1.1.1.1 $
15  * $Date: 2000/11/13 02:42:38 $
16  * $Author: holsta $
17  * $State: Exp $
18  * $Locker:  $
19  *
20  * ---------------------------------------------------------------------------
21  *****************************************************************************/
22 
23 #ifndef BANS_H
24 #define BANS_H
25 
26 typedef struct KickStruct {
27   struct Header h;
28   char *pattern;    /* user account */
29   char *nick;       /* last used nick name */
30   char *kickmsg;    /* reason */
31   long kicks;       /* counter of kicks within KICK_PERIOD */
32   long botkicks;    /* kicks by the bot */
33   long trustkicks;  /* kicks when trusted user */
34   long totkicks;    /* total count of kicks */
35   time_t lastkick;  /* time of last kick */
36   char *kicker;     /* last kicker */
37   bool norecurse;   /* to prevent recursion of the same pattern in
38 		       the AddKick() function */
39 } itemkick;
40 
41 extern itemkick* kickHead;
42 
43 void BanKick(char *nick, char *banthis, char *message, char *remove);
44 void BanTimeout(void);
45 
46 int AddToBanList(int flags, char *who, char *nick, char *pattern,
47                   int secs, char *reason);
48 bool ChangeInBanList(char *who, char *bannick, int newsecs,
49                      char *pattern, char flag, char *reason);
50 bool UnBan(char *from, char *nick);
51 void Unbanned(char *from, char *pattern, bool bot);
52 void BanInit(void);
53 bool IsUnban(char *pattern);
54 bool IsBanListed(char *pattern);
55 bool IsBan(char *pattern);
56 char *IsMatchBan(char *checkthis, int *);
57 void BanDisable(void);
58 bool IllegalBan(char *);
59 void BanSave(void);
60 void BanCleanup(void);
61 bool UnbanLoprio(char *from);
62 
63 bool AddKick(itemident *, char *, char *, int);
64 void FreeKick(void *v);
65 void KickAll(char *pattern, char *msg);
66 void KickInit(void);
67 void KickCleanup(void);
68 void KickList(char *, char *);
69 bool KickFromQueue(time_t *);
70 itemkick *KickMatch(char *pattern);
71 
72 void WarnInit(void);
73 void WarnCleanup(void);
74 bool WarnAdd(char *, char *, char *, char *, char *, int);
75 void WarnSave(void);
76 bool WarnDel(char *, char *);
77 bool WarnList(char *, char *, int);
78 bool WarnCheck(char *, char *);
79 int CountWarns(int);
80 
81 #define BANLIST_ALERTSIZE 18 /* warn in public when we have this many, or
82                                 more, bans in the list */
83 #define REFRESH_TIMEOUT (30*SECINMIN)
84 #define SERVERBANTIMEOUT 30 /* give 30 secs to complete server bans */
85 #define BAN_ENFTIMEOUT (1<<0) /* timeouted enforced ban */
86 #define BAN_ENFORCE (1<<1) /* make this always present */
87 #define BAN_ACTUAL  (1<<2) /* this is guaranteed to be a valid channel-
88                               ban == we got this from the banlist or from a
89                               mode change within the channel */
90 #define BAN_UNBAN   (1<<3) /* this is unbanned */
91 #define BAN_UNSET   (1<<4) /* this is read from the file when bottie was
92                               started and not yet set */
93 #define BAN_SENTUNBAN (1<<5) /* unban sent to server */
94 #define BAN_SENTBAN   (1<<6) /* ban sent to server */
95 #define BAN_GUESSNICK (1<<7) /* guessed the nick, may be wrong */
96 #define BAN_ALL     ~0     /* all flags */
97 
98 /*
99  * An easy-to-use define to see if the ban is there or about to pop up soon:
100  */
101 #define BANISTHERE (BAN_ACTUAL|BAN_SENTBAN)
102 
103 /* required level that unbans enforced bans just like any other ban */
104 #define BAN_ENFORCELEVEL LEVELBOT
105 
106 #define BANRETRY_ENFORCE 30  /* number of minutes to wait until an enforced
107                                 ban is rebanned after unbanned twice rapidly
108                               */
109 
110 /* We don't save warnings to the warn file that were set and not warned for
111    during this period of time: */
112 #define WARN_TIMEOUT_REMOVAL (SECINMONTH*3)
113 
114 #define CHBAN_ENFORCE    1
115 #define CHBAN_UNENFORCE  2
116 #define CHBAN_REASON     3
117 
118 #define KICK_TRUSTEDUSER 2
119 #define KICK_BOT         1
120 #define KICK_COMMON      0
121 
122 #define WARNF_KICKBAN 1    /* kick user and ban pattern on sight */
123 #define WARNF_ALL     0xff /* all warn flags ORed */
124 
125 #define WLIST_ALL 1 /* list all info */
126 #define WLIST_BAN 2 /* list only bans */
127 
128 #define BLIST_ACTUAL 1   /* present and ACTUAL in the list */
129 #define BLIST_PRESENT -1 /* present in list, but not ACTUAL */
130 #define BLIST_NOTHERE 0  /* unbanned or not existing before */
131 
132 #endif /* BANS_H */
133