Anope IRC Services  Version 1.8
cs_drop.c
Go to the documentation of this file.
1 /* ChanServ 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_drop(User * u);
18 static void myChanServHelp(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("DROP", do_drop, NULL, -1, CHAN_HELP_DROP, -1,
35  CHAN_SERVADMIN_HELP_DROP, CHAN_SERVADMIN_HELP_DROP);
37 
39 
40  return MOD_CONT;
41 }
42 
46 void AnopeFini(void)
47 {
48 
49 }
50 
51 
52 
57 static void myChanServHelp(User * u)
58 {
59  notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DROP);
60 }
61 
67 static int do_drop(User * u)
68 {
69  char *chan = strtok(NULL, " ");
70  ChannelInfo *ci;
71  int is_servadmin = is_services_admin(u);
72 
73  if (readonly && !is_servadmin) {
74  notice_lang(s_ChanServ, u, CHAN_DROP_DISABLED);
75  return MOD_CONT;
76  }
77 
78  if (!chan) {
79  syntax_error(s_ChanServ, u, "DROP", CHAN_DROP_SYNTAX);
80  } else if (!(ci = cs_findchan(chan))) {
81  notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
82  } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) {
83  notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
84  } else if (!is_servadmin && (ci->flags & CI_SUSPENDED)) {
85  notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
86  } else if (!is_servadmin
87  && (ci->
88  flags & CI_SECUREFOUNDER ? !is_real_founder(u,
89  ci) :
90  !is_founder(u, ci))) {
91  notice_lang(s_ChanServ, u, ACCESS_DENIED);
92  } else {
93  int level = get_access(u, ci);
94 
95  if (readonly) /* in this case we know they're a Services admin */
96  notice_lang(s_ChanServ, u, READ_ONLY_MODE);
97 
98  if (ci->c) {
99  if (ircd->regmode) {
100  ci->c->mode &= ~ircd->regmode;
101  anope_cmd_mode(whosends(ci), ci->name, "-r");
102  }
103  }
104 
105  if (ircd->chansqline && (ci->flags & CI_VERBOTEN)) {
107  }
108 
109  alog("%s: Channel %s dropped by %s!%s@%s (founder: %s)",
110  s_ChanServ, ci->name, u->nick, u->username,
111  u->host, (ci->founder ? ci->founder->display : "(none)"));
112 
113  delchan(ci);
114 
115  /* We must make sure that the Services admin has not normally the right to
116  * drop the channel before issuing the wallops.
117  */
118  if (WallDrop && is_servadmin && level < ACCESS_FOUNDER)
120  "\2%s\2 used DROP on channel \2%s\2", u->nick,
121  chan);
122 
123  notice_lang(s_ChanServ, u, CHAN_DROPPED, chan);
124  send_event(EVENT_CHAN_DROP, 1, chan);
125  }
126  return MOD_CONT;
127 }
#define CI_SUSPENDED
Definition: services.h:743
void AnopeFini(void)
Definition: cs_drop.c:46
E int readonly
Definition: extern.h:776
char nick[NICKMAX]
Definition: services.h:875
static void myChanServHelp(User *u)
Definition: cs_drop.c:57
E IRCDVar * ircd
Definition: extern.h:39
E void send_event(const char *name, int argc,...)
Definition: events.c:37
uint32 regmode
Definition: services.h:336
#define CI_VERBOTEN
Definition: services.h:725
#define CI_SECUREFOUNDER
Definition: services.h:735
char * host
Definition: services.h:878
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
char * display
Definition: services.h:542
#define ACCESS_FOUNDER
Definition: services.h:604
static int do_drop(User *u)
Definition: cs_drop.c:67
uint32 flags
Definition: services.h:669
uint32 mode
Definition: services.h:1006
E int WallDrop
Definition: extern.h:466
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
struct channel_ * c
Definition: services.h:692
MDE void moduleSetChanHelp(void(*func)(User *u))
Definition: modules.c:2090
int chansqline
Definition: services.h:325
E int is_real_founder(User *user, ChannelInfo *ci)
Definition: chanserv.c:2277
Command * c
Definition: ns_recover.c:17
#define CHANSERV
Definition: modules.h:60
E void alog(const char *fmt,...) FORMAT(printf
E void anope_cmd_unsqline(char *user)
Definition: ircd.c:357
#define MOD_CONT
Definition: modules.h:54
E int is_founder(User *user, ChannelInfo *ci)
Definition: chanserv.c:2255
E int delchan(ChannelInfo *ci)
Definition: chanserv.c:2063
E int is_services_admin(User *u)
Definition: operserv.c:591
#define whosends(ci)
Definition: extern.h:163
char * username
Definition: services.h:877
int AnopeInit(int argc, char **argv)
Definition: cs_drop.c:26
E void anope_cmd_mode(char *source, char *dest, const char *fmt,...)
Definition: ircd.c:211
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 ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
E char * s_ChanServ
Definition: extern.h:285
E int get_access(User *user, ChannelInfo *ci)
Definition: chanserv.c:2332
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
NickCore * founder
Definition: services.h:655
#define EVENT_CHAN_DROP
Definition: events.h:33
#define MOD_UNIQUE
Definition: module.h:11
E void anope_cmd_global(char *source, const char *fmt,...)
Definition: ircd.c:506