Anope IRC Services  Version 1.8
os_ignore.c
Go to the documentation of this file.
1 /* OperServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 static int do_ignorelist(User * u);
18 static void myOperServHelp(User * u);
19 static int do_ignoreuser(User * u);
20 
27 int AnopeInit(int argc, char **argv)
28 {
29  Command *c;
30 
31  moduleAddAuthor("Anope");
32  moduleAddVersion(VERSION_STRING);
35  OPER_HELP_IGNORE, -1, -1, -1, -1);
37 
39 
40  return MOD_CONT;
41 }
42 
46 void AnopeFini(void)
47 {
48 
49 }
50 
51 
56 static void myOperServHelp(User * u)
57 {
58  if (is_services_admin(u)) {
59  notice_lang(s_OperServ, u, OPER_HELP_CMD_IGNORE);
60  }
61 }
62 
68 static int do_ignoreuser(User * u)
69 {
70  char *cmd = strtok(NULL, " ");
71  int t;
72 
73  if (!cmd) {
74  syntax_error(s_OperServ, u, "IGNORE", OPER_IGNORE_SYNTAX);
75  return MOD_CONT;
76  }
77 
78  if (!stricmp(cmd, "ADD")) {
79  char *time = strtok(NULL, " ");
80  char *nick = strtok(NULL, " ");
81 
82  if (!nick) {
83  syntax_error(s_OperServ, u, "IGNORE", OPER_IGNORE_SYNTAX);
84  return MOD_CONT;
85  } else if (!time) {
86  syntax_error(s_OperServ, u, "IGNORE", OPER_IGNORE_SYNTAX);
87  return MOD_CONT;
88  } else {
89  t = dotime(time);
90 
91  if (t <= -1) {
92  notice_lang(s_OperServ, u, OPER_IGNORE_VALID_TIME);
93  return MOD_CONT;
94  } else if (t == 0) {
95  add_ignore(nick, t);
96  notice_lang(s_OperServ, u, OPER_IGNORE_PERM_DONE, nick);
97  } else {
98  add_ignore(nick, t);
99  notice_lang(s_OperServ, u, OPER_IGNORE_TIME_DONE, nick, time);
100  }
101  }
102  } else if (!stricmp(cmd, "LIST")) {
103  do_ignorelist(u);
104 
105  } else if (!stricmp(cmd, "DEL")) {
106  char *nick = strtok(NULL, " ");
107  if (!nick) {
108  syntax_error(s_OperServ, u, "IGNORE", OPER_IGNORE_SYNTAX);
109  } else {
110  if (delete_ignore(nick)) {
111  notice_lang(s_OperServ, u, OPER_IGNORE_DEL_DONE, nick);
112  return MOD_CONT;
113  }
114  notice_lang(s_OperServ, u, OPER_IGNORE_LIST_NOMATCH, nick);
115  }
116  } else if (!stricmp(cmd, "CLEAR")) {
117  clear_ignores();
118  notice_lang(s_OperServ, u, OPER_IGNORE_LIST_CLEARED);
119  return MOD_CONT;
120  } else
121  syntax_error(s_OperServ, u, "IGNORE", OPER_IGNORE_SYNTAX);
122 
123  return MOD_CONT;
124 }
125 
126 /* shows the Services ignore list */
127 static int do_ignorelist(User * u)
128 {
129  IgnoreData *id;
130 
131  if (!ignore) {
132  notice_lang(s_OperServ, u, OPER_IGNORE_LIST_EMPTY);
133  return MOD_CONT;
134  }
135 
136  notice_lang(s_OperServ, u, OPER_IGNORE_LIST);
137  for (id = ignore; id; id = id->next)
138  notice_user(s_OperServ, u, "%s", id->mask);
139 
140  return MOD_CONT;
141 }
142 
143 /* EOF */
int AnopeInit(int argc, char **argv)
Definition: os_ignore.c:27
E int dotime(const char *s)
Definition: misc.c:364
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
E void E void E void E void notice_user(char *source, User *u, const char *fmt,...) FORMAT(printf
E int clear_ignores()
Definition: process.c:241
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E IgnoreData * ignore
Definition: extern.h:1022
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
struct ignore_data * next
Definition: services.h:1058
#define OPERSERV
Definition: modules.h:62
E char * s_OperServ
Definition: extern.h:289
E int delete_ignore(const char *nick)
Definition: process.c:179
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
static void myOperServHelp(User *u)
Definition: os_ignore.c:56
Command * c
Definition: ns_recover.c:17
static int do_ignoreuser(User *u)
Definition: os_ignore.c:68
char * mask
Definition: services.h:1059
E void add_ignore(const char *nick, time_t delta)
Definition: process.c:33
MDE void moduleSetOperHelp(void(*func)(User *u))
Definition: modules.c:2126
#define MOD_CONT
Definition: modules.h:54
E int is_services_admin(User *u)
Definition: operserv.c:591
void AnopeFini(void)
Definition: os_ignore.c:46
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
static int do_ignorelist(User *u)
Definition: os_ignore.c:127
#define MOD_UNIQUE
Definition: module.h:11