Anope IRC Services  Version 1.8
bs_fantasy.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");
30  moduleAddVersion(VERSION_STRING);
33  moduleAddEventHook(hook);
34 
35  return MOD_CONT;
36 }
37 
41 void AnopeFini(void)
42 {
43 
44 }
45 
52 static int do_fantasy(int argc, char **argv)
53 {
54  User *u;
55  ChannelInfo *ci;
56  CSModeUtil *util = csmodeutils;
57  char *target;
58 
59  if (argc < 3)
60  return MOD_CONT;
61 
62  do {
63  if (stricmp(argv[0], util->bsname) == 0) {
64  /* This could have been moved to its own module
65  however it would require more coding to handle the pass holders
66  similar to how PROTECT is done
67  */
68  if (!ircd->halfop) {
69  if (!stricmp(argv[0], "halfop") || !stricmp(argv[0], "dehalfop")) {
70  return MOD_CONT;
71  }
72  }
73  u = finduser(argv[1]);
74  ci = cs_findchan(argv[2]);
75  if (!u || !ci)
76  return MOD_CONT;
77 
78  target = ((argc == 4) ? argv[3] : NULL);
79 
80  if (!target && check_access(u, ci, util->levelself))
81  bot_raw_mode(u, ci, util->mode, u->nick);
82  else if (target && check_access(u, ci, util->level))
83  bot_raw_mode(u, ci, util->mode, target);
84  }
85  } while ((++util)->name != NULL);
86 
87  return MOD_CONT;
88 }
char nick[NICKMAX]
Definition: services.h:875
void AnopeFini(void)
Definition: bs_fantasy.c:41
E IRCDVar * ircd
Definition: extern.h:39
int AnopeInit(int argc, char **argv)
Definition: bs_fantasy.c:25
E int check_access(User *user, ChannelInfo *ci, int what)
Definition: chanserv.c:1974
int levelself
Definition: services.h:831
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
char * mode
Definition: services.h:828
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
MDE void moduleSetType(MODType type)
Definition: modules.c:818
static int do_fantasy(int argc, char **argv)
Definition: bs_fantasy.c:52
E User * finduser(const char *nick)
Definition: users.c:323
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
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
E ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
E void bot_raw_mode(User *requester, ChannelInfo *ci, char *mode, char *nick)
Definition: botserv.c:1048
int halfop
Definition: services.h:316
char * bsname
Definition: services.h:827
MDE int moduleAddEventHook(EvtHook *evh)
Definition: events.c:528
E CSModeUtil csmodeutils[]
Definition: extern.h:168