Anope IRC Services  Version 1.8
cs_help.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_help(User * u);
18 
25 int AnopeInit(int argc, char **argv)
26 {
27  Command *c;
28 
29  moduleAddAuthor("Anope");
30  moduleAddVersion(VERSION_STRING);
32 
33  c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1);
35 
36  return MOD_CONT;
37 }
38 
42 void AnopeFini(void)
43 {
44 
45 }
46 
52 static int do_help(User * u)
53 {
54  char *cmd = strtok(NULL, "");
55 
56  if (!cmd) {
57  notice_help(s_ChanServ, u, CHAN_HELP);
58  moduleDisplayHelp(2, u);
59  if (CSExpire >= 86400)
60  notice_help(s_ChanServ, u, CHAN_HELP_EXPIRES,
61  CSExpire / 86400);
62  if (is_services_oper(u))
63  notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP);
64  } else if (stricmp(cmd, "LEVELS DESC") == 0) {
65  int i;
66  notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC);
67  if (!levelinfo_maxwidth) {
68  for (i = 0; levelinfo[i].what >= 0; i++) {
69  int len = strlen(levelinfo[i].name);
70  if (len > levelinfo_maxwidth)
71  levelinfo_maxwidth = len;
72  }
73  }
74  for (i = 0; levelinfo[i].what >= 0; i++) {
75  notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC_FORMAT,
77  getstring(u->na, levelinfo[i].desc));
78  }
79  } else {
81  }
82  return MOD_CONT;
83 }
MDE void mod_help_cmd(char *service, User *u, CommandHash *cmdTable[], const char *cmd)
Definition: commands.c:266
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
#define getstring(na, index)
Definition: extern.h:731
void AnopeFini(void)
Definition: cs_help.c:42
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
MDE void moduleSetType(MODType type)
Definition: modules.c:818
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
int what
Definition: services.h:835
MDE void moduleDisplayHelp(int service, User *u)
Definition: modules.c:2162
Command * c
Definition: ns_recover.c:17
#define CHANSERV
Definition: modules.h:60
E void notice_help(char *source, User *dest, int message,...)
Definition: send.c:220
#define MOD_CONT
Definition: modules.h:54
E LevelInfo levelinfo[]
Definition: extern.h:169
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 int CSExpire
Definition: extern.h:404
static int do_help(User *u)
Definition: cs_help.c:52
E int is_services_oper(User *u)
Definition: operserv.c:606
E int levelinfo_maxwidth
Definition: extern.h:224
int desc
Definition: services.h:837
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_help.c:25
NickAlias * na
Definition: services.h:892
#define MOD_UNIQUE
Definition: module.h:11