Anope IRC Services  Version 1.8
cs_getkey.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_getkey(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("GETKEY", do_getkey, NULL, CHAN_HELP_GETKEY, -1, -1,
35  -1, -1);
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_GETKEY);
60 }
61 
67 static int do_getkey(User * u)
68 {
69  char *chan = strtok(NULL, " ");
70  ChannelInfo *ci;
71 
72  if (!chan) {
73  syntax_error(s_ChanServ, u, "GETKEY", CHAN_GETKEY_SYNTAX);
74  } else if (!(ci = cs_findchan(chan))) {
75  notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
76  } else if (ci->flags & CI_VERBOTEN) {
77  notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
78  } else if (!check_access(u, ci, CA_GETKEY)) {
79  notice_lang(s_ChanServ, u, ACCESS_DENIED);
80  } else if (!ci->c || !ci->c->key) {
81  notice_lang(s_ChanServ, u, CHAN_GETKEY_NOKEY, chan);
82  } else {
83  alog("%s: %s!%s@%s used GETKEY on %s",
84  s_ChanServ, u->nick, u->username, u->host, ci->name);
85  notice_lang(s_ChanServ, u, CHAN_GETKEY_KEY, chan, ci->c->key);
86  }
87 
88  return MOD_CONT;
89 }
#define CA_GETKEY
Definition: services.h:770
static void myChanServHelp(User *u)
Definition: cs_getkey.c:57
char nick[NICKMAX]
Definition: services.h:875
void AnopeFini(void)
Definition: cs_getkey.c:46
E int check_access(User *user, ChannelInfo *ci, int what)
Definition: chanserv.c:1974
#define CI_VERBOTEN
Definition: services.h:725
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
uint32 flags
Definition: services.h:669
char * key
Definition: services.h:1008
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
Command * c
Definition: ns_recover.c:17
#define CHANSERV
Definition: modules.h:60
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_CONT
Definition: modules.h:54
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
static int do_getkey(User *u)
Definition: cs_getkey.c:67
E ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
E char * s_ChanServ
Definition: extern.h:285
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
int AnopeInit(int argc, char **argv)
Definition: cs_getkey.c:26
#define MOD_UNIQUE
Definition: module.h:11