Anope IRC Services  Version 1.8
bs_unassign.c
Go to the documentation of this file.
1 /* BotServ 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_unassign(User * u);
18 static void myBotServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33  c = createCommand("UNASSIGN", do_unassign, NULL, BOT_HELP_UNASSIGN, -1,
34  -1, -1, -1);
36 
38 
39  return MOD_CONT;
40 }
41 
45 void AnopeFini(void)
46 {
47 
48 }
49 
50 
51 
56 static void myBotServHelp(User * u)
57 {
58  notice_lang(s_BotServ, u, BOT_HELP_CMD_UNASSIGN);
59 }
60 
66 static int do_unassign(User * u)
67 {
68  char *chan = strtok(NULL, " ");
69  ChannelInfo *ci;
70 
71  if (readonly)
72  notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY);
73  else if (!chan)
74  syntax_error(s_BotServ, u, "UNASSIGN", BOT_UNASSIGN_SYNTAX);
75  else if (!(ci = cs_findchan(chan)))
76  notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
77  else if (ci->flags & CI_VERBOTEN)
78  notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
79  else if (!is_services_admin(u) && !check_access(u, ci, CA_ASSIGN))
80  notice_lang(s_BotServ, u, ACCESS_DENIED);
81  else if (!ci->bi)
82  notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
83  else {
84  alog("%s: %s!%s@%s unassigned bot %s from %s", s_BotServ, u->nick, u->username,
85  u->host, ci->bi->nick, ci->name);
86  unassign(u, ci);
87  notice_lang(s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name);
88  }
89  return MOD_CONT;
90 }
E int readonly
Definition: extern.h:776
char nick[NICKMAX]
Definition: services.h:875
E char * s_BotServ
Definition: extern.h:287
E int check_access(User *user, ChannelInfo *ci, int what)
Definition: chanserv.c:1974
static int do_unassign(User *u)
Definition: bs_unassign.c:66
#define CI_VERBOTEN
Definition: services.h:725
int AnopeInit(int argc, char **argv)
Definition: bs_unassign.c:26
char * host
Definition: services.h:878
E void unassign(User *u, ChannelInfo *ci)
Definition: botserv.c:637
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
char name[CHANMAX]
Definition: services.h:654
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
uint32 flags
Definition: services.h:669
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
#define BOTSERV
Definition: modules.h:57
E void notice_help(char *source, User *dest, int message,...)
Definition: send.c:220
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_CONT
Definition: modules.h:54
static void myBotServHelp(User *u)
Definition: bs_unassign.c:56
MDE void moduleSetBotHelp(void(*func)(User *u))
Definition: modules.c:2114
E int is_services_admin(User *u)
Definition: operserv.c:591
char * username
Definition: services.h:877
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
char * nick
Definition: services.h:573
E ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
BotInfo * bi
Definition: services.h:699
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define CA_ASSIGN
Definition: services.h:762
#define MOD_UNIQUE
Definition: module.h:11
void AnopeFini(void)
Definition: bs_unassign.c:45