Anope IRC Services  Version 1.8
bs_fantasy_unban.c
Go to the documentation of this file.
1 /* BotServ core fantasy 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_fantasy(int argc, char **argv);
18 
25 int AnopeInit(int argc, char **argv)
26 {
27  EvtHook *hook;
28 
29  moduleAddAuthor("Anope");
31  (VERSION_STRING);
33 
35  moduleAddEventHook(hook);
36 
37  return MOD_CONT;
38 }
39 
43 void AnopeFini(void)
44 {
45 
46 }
47 
54 static int do_fantasy(int argc, char **argv)
55 {
56  User *u;
57  ChannelInfo *ci;
58  char *target = NULL;
59 
60  if (argc < 3)
61  return MOD_CONT;
62 
63  if (stricmp(argv[0], "unban") == 0) {
64  u = finduser(argv[1]);
65  ci = cs_findchan(argv[2]);
66  if (!u || !ci || !check_access(u, ci, CA_UNBAN))
67  return MOD_CONT;
68 
69  if (argc >= 4)
70  target = myStrGetToken(argv[3], ' ', 0);
71  if (!target)
72  common_unban_full(ci, u->nick, true);
73  else
74  common_unban(ci, target);
75 
76  /* free target if needed (#852) */
77  Anope_Free(target);
78  }
79 
80  return MOD_CONT;
81 }
#define Anope_Free(x)
Definition: extern.h:1391
char nick[NICKMAX]
Definition: services.h:875
E int check_access(User *user, ChannelInfo *ci, int what)
Definition: chanserv.c:1974
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
MDE void moduleSetType(MODType type)
Definition: modules.c:818
E void common_unban(ChannelInfo *ci, char *nick)
Definition: actions.c:209
#define CA_UNBAN
Definition: services.h:752
E User * finduser(const char *nick)
Definition: users.c:323
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
E void common_unban_full(ChannelInfo *ci, char *nick, boolean full)
Definition: actions.c:214
MDE EvtHook * createEventHook(char *name, int(*func)(int argc, char **argv))
Definition: events.c:305
#define MOD_CONT
Definition: modules.h:54
#define EVENT_BOT_FANTASY
Definition: events.h:24
Definition: modules.h:99
void AnopeFini(void)
E char * myStrGetToken(const char *str, const char dilim, int token_number)
Definition: misc.c:654
E ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
int AnopeInit(int argc, char **argv)
static int do_fantasy(int argc, char **argv)
MDE int moduleAddEventHook(EvtHook *evh)
Definition: events.c:528