Anope IRC Services  Version 1.8
hs_moo.c
Go to the documentation of this file.
1 
9 #include "module.h"
10 
11 #define AUTHOR "Anope" /* Set the Author for a modinfo reply */
12 #define VERSION VERSION_STRING /* Set the version for a modinfo reply */
13 
14 int hs_moo_show(User * u); /* Function to use when a /hs moo command is recived */
15 int test(int argc, char **argv);
16 void myHostServHelp(User *u); /* Function to display out help in a /hs help response */
17 int myHostServMooHelp(User *u); /* Function to display help to _everyone_ when a /hs help moo is called*/
18 int myHostServMooRegHelp(User *u); /* Function to display extra help to regular-users when a /hs help moo is called*/
19 int myHostServMooOperHelp(User *u); /* Function to display extra help to opers when a /hs help moo is called*/
20 int myHostServMooAdminHelp(User *u); /* Function to display extra help to admins when a /hs help moo is called*/
21 int myHostServMooRootHelp(User *u); /* Function to display extra help to roors when a /hs help moo is called*/
22 
23 int AnopeInit(int argc, char **argv) /* This will be executed when the module is loaded */
24 {
25  Command *c; /* Pointer to a Command */
26  int status = 0; /* the status of our new command */
27  c = createCommand("moo", hs_moo_show, NULL, -1, -1, -1, -1, -1); /* Create a new command "moo" pointing to hs_moo */
28 
29  moduleAddHelp(c,myHostServMooHelp); /* add help for all users to this command */
30  moduleAddRegHelp(c,myHostServMooRegHelp); /* add extra regular-user only help to this command */
31  moduleAddOperHelp(c,myHostServMooOperHelp); /* add extra oper only help to this command */
32  moduleAddAdminHelp(c,myHostServMooAdminHelp); /* add extra admin only help to this command */
33  moduleAddRootHelp(c,myHostServMooRootHelp); /* add extra root only help to this command */
34 
35  moduleSetHostHelp(myHostServHelp); /* add us to the .hs help list */
36 
37  status = moduleAddCommand(HOSTSERV, c, MOD_HEAD); /* Add the command to the HOSTSERV cmd table */
38 
39  /* Check if we have any argv's */
40  if(argc>0) {
41  /* we do, the first will be the nick of the person modload'ing us */
42  /* or NULL if we were auto-loaded */
43  if(argv[0]) {
44  alog("hs_moo was modloaded by: [%s]",argv[0]);
45  } else {
46  alog("hs_moo was automatically loaded by anope");
47  }
48  }
49  alog("hs_moo.so: Add Command 'moo' Status: %d",status); /* Log the command being added */
50 
51  moduleAddCallback("test",time(NULL)+dotime("15s"),test,0,NULL); /* set a call-back function to exec in 3 mins time */
52  moduleDelCallback("test");
53  moduleAddAuthor(AUTHOR); /* tell Anope about the author */
54  moduleAddVersion(VERSION); /* Tell Anope about the verison */
55 
56  if(status!=MOD_ERR_OK) {
57  return MOD_STOP;
58  }
59  return MOD_CONT;
60 }
61 
62 int hs_moo_show(User * u)
63 {
64  notice(s_HostServ, u->nick, "MOO! - This command was loaded via a module!"); /* Just notice the user */
65  return MOD_STOP; /* MOD_STOP means we will NOT pass control back to other */
66 } /* modules waiting to handle the /hs moo command! */
67 
68 int test(int argc, char **argv) {
69  alog("CallBack from hs_moo with %d paramaters",argc);
70  return MOD_CONT;
71 }
72 
73 void AnopeFini(void)
74 {
75  /* module is unloading */
76 }
77 
78 /***************************************************************************************************************************************/
79 /* The code below here shows various ways of dealing with the module help system */
80 /***************************************************************************************************************************************/
81 
82 void myHostServHelp(User *u) {
83  notice(s_HostServ,u->nick, " MOO Moos at the user!"); /* this will appear in the help list */
84 }
85 
87  notice(s_HostServ,u->nick,"Syntax: Moo"); /* this will be sent to everyone who does /msg hostserv help moo */
88  notice(s_HostServ,u->nick,"This command is an example provided");
89  notice(s_HostServ,u->nick,"by the Anope development team.");
90  return MOD_CONT; /* allow any other module's with help for /hs moo to run */
91 }
92 
93 int myHostServMooRootHelp(User *u) { /* this will only be sent to ROOTS ONLY who /msg hostserv moo */
94  myHostServMooAdminHelp(u); /* this line lets us show roots the ADMIN help as well as the root help */
95  notice(s_HostServ,u->nick,"Only roots will see this part of the help");
96  return MOD_CONT;
97 }
98 
99 int myHostServMooAdminHelp(User *u) { /* this will only be sent to ADMINS ONLY who /msg hostserv moo */
100  myHostServMooOperHelp(u); /* this line lets us show admins the OPER help as well as the admin help */
101  notice(s_HostServ,u->nick,"Only admins will see this part of the help");
102  notice(s_HostServ,u->nick,"why not visit us on www.anope.org ?");
103  return MOD_CONT;
104 }
105 
106 int myHostServMooOperHelp(User *u) { /* this will only be sent to OPERS ONLY who /msg hostserv moo */
107  notice(s_HostServ,u->nick,"Only opers will see this part of the help");
108  notice(s_HostServ,u->nick,"for more help/support with modules");
109  notice(s_HostServ,u->nick,"visit us on irc.anope.org #anope! :)");
110  return MOD_CONT;
111 }
112 
113 int myHostServMooRegHelp(User *u) { /* this will only be sent to REGULAR USERS ONLY who /msg hostserv moo */
114  notice(s_HostServ,u->nick,"Only non-opers will see this part of the help");
115  notice(s_HostServ,u->nick,"as we've left it hidden from opers");
116  return MOD_CONT;
117 }
118 
119 /* EOF */
void myHostServHelp(User *u)
Definition: hs_moo.c:82
char nick[NICKMAX]
Definition: services.h:875
MDE int moduleAddOperHelp(Command *c, int(*func)(User *u))
Definition: modules.c:2036
void AnopeFini(void)
Definition: hs_moo.c:73
MDE int moduleAddRegHelp(Command *c, int(*func)(User *u))
Definition: modules.c:2050
int myHostServMooAdminHelp(User *u)
Definition: hs_moo.c:99
E int dotime(const char *s)
Definition: misc.c:364
E void notice(char *source, char *dest, const char *fmt,...)
Definition: send.c:274
int hs_moo_show(User *u)
Definition: hs_moo.c:62
int myHostServMooRegHelp(User *u)
Definition: hs_moo.c:113
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
#define HOSTSERV
Definition: modules.h:56
#define VERSION
Definition: hs_moo.c:12
#define MOD_STOP
Definition: modules.h:53
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_ERR_OK
Definition: modules.h:71
MDE int moduleAddRootHelp(Command *c, int(*func)(User *u))
Definition: modules.c:2008
int AnopeInit(int argc, char **argv)
Definition: hs_moo.c:23
#define AUTHOR
Definition: hs_moo.c:11
#define MOD_CONT
Definition: modules.h:54
int myHostServMooRootHelp(User *u)
Definition: hs_moo.c:93
E char * s_HostServ
Definition: extern.h:303
int myHostServMooOperHelp(User *u)
Definition: hs_moo.c:106
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
int myHostServMooHelp(User *u)
Definition: hs_moo.c:86
MDE void moduleDelCallback(char *name)
Definition: modules.c:1927
MDE int moduleAddHelp(Command *c, int(*func)(User *u))
Definition: modules.c:2064
MDE int moduleAddCallback(char *name, time_t when, int(*func)(int argc, char *argv[]), int argc, char **argv)
Definition: modules.c:1794
int test(int argc, char **argv)
Definition: hs_moo.c:68
MDE int moduleAddAdminHelp(Command *c, int(*func)(User *u))
Definition: modules.c:2022
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define MOD_HEAD
Definition: module.h:12
MDE void moduleSetHostHelp(void(*func)(User *u))
Definition: modules.c:2138