Anope IRC Services  Version 1.8
os_kick.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_os_kick(User * u);
18 static void myOperServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33 
34  c = createCommand("KICK", do_os_kick, is_services_oper, OPER_HELP_KICK,
35  -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_oper(u)) {
59  notice_lang(s_OperServ, u, OPER_HELP_CMD_KICK);
60  }
61 }
62 
68 static int do_os_kick(User * u)
69 {
70  char *argv[3];
71  char *chan, *nick, *s;
72  Channel *c;
73 
74  chan = strtok(NULL, " ");
75  nick = strtok(NULL, " ");
76  s = strtok(NULL, "");
77  if (!chan || !nick || !s) {
78  syntax_error(s_OperServ, u, "KICK", OPER_KICK_SYNTAX);
79  return MOD_CONT;
80  }
81  if (!(c = findchan(chan))) {
82  notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
83  } else if (c->bouncy_modes) {
84  notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
85  return MOD_CONT;
86  }
87  anope_cmd_kick(s_OperServ, chan, nick, "%s (%s)", u->nick, s);
88  if (WallOSKick)
89  anope_cmd_global(s_OperServ, "%s used KICK on %s/%s", u->nick,
90  nick, chan);
91  argv[0] = sstrdup(chan);
92  argv[1] = sstrdup(nick);
93  argv[2] = sstrdup(s);
94  do_kick(s_OperServ, 3, argv);
95  free(argv[2]);
96  free(argv[1]);
97  free(argv[0]);
98  return MOD_CONT;
99 }
char nick[NICKMAX]
Definition: services.h:875
E void do_kick(const char *source, int ac, char **av)
Definition: channels.c:638
int AnopeInit(int argc, char **argv)
Definition: os_kick.c:26
E int WallOSKick
Definition: extern.h:453
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
static void myOperServHelp(User *u)
Definition: os_kick.c:56
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
E Channel * findchan(const char *chan)
Definition: channels.c:394
int16 bouncy_modes
Definition: services.h:1028
E char * sstrdup(const char *s)
Definition: memory.c:105
E void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt,...)
Definition: ircd.c:230
#define OPERSERV
Definition: modules.h:62
E char * s_OperServ
Definition: extern.h:289
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
static int do_os_kick(User *u)
Definition: os_kick.c:68
MDE void moduleSetOperHelp(void(*func)(User *u))
Definition: modules.c:2126
#define MOD_CONT
Definition: modules.h:54
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
E int is_services_oper(User *u)
Definition: operserv.c:606
void AnopeFini(void)
Definition: os_kick.c:46
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506