hs_moo.c

Go to the documentation of this file.
00001 
00009 #include "module.h"
00010 
00011 #define AUTHOR "Anope"                                                                  /* Set the Author for a modinfo reply */
00012 #define VERSION "$Id: hs_moo.c 953 2006-01-14 11:36:29Z certus $"                                                                       /* Set the version for a modinfo reply */
00013 
00014 int hs_moo_show(User * u);                                                                      /* Function to use when a /hs moo command is recived */
00015 int test(int argc, char **argv);
00016 void myHostServHelp(User *u);                                                           /* Function to display out help in a /hs help response */
00017 int myHostServMooHelp(User *u);                                                                 /* Function to display help to _everyone_ when a /hs help moo is called*/
00018 int myHostServMooRegHelp(User *u);                                                       /* Function to display extra help to regular-users when a /hs help moo is called*/
00019 int myHostServMooOperHelp(User *u);                                              /* Function to display extra help to opers when a /hs help moo is called*/
00020 int myHostServMooAdminHelp(User *u);                                             /* Function to display extra help to admins when a /hs help moo is called*/
00021 int myHostServMooRootHelp(User *u);                                              /* Function to display extra help to roors when a /hs help moo is called*/
00022 
00023 int AnopeInit(int argc, char **argv)                                                    /* This will be executed when the module is loaded */
00024 {
00025     Command *c;                                                                                 /* Pointer to a Command */
00026     int status = 0;                                                                                     /* the status of our new command */
00027     c = createCommand("moo", hs_moo_show, NULL, -1, -1, -1, -1, -1);    /* Create a new command "moo" pointing to hs_moo */
00028 
00029     moduleAddHelp(c,myHostServMooHelp);                                         /* add help for all users to this command */
00030     moduleAddRegHelp(c,myHostServMooRegHelp);                           /* add extra regular-user only help to this command */
00031     moduleAddOperHelp(c,myHostServMooOperHelp);                         /* add extra oper only help to this command */
00032     moduleAddAdminHelp(c,myHostServMooAdminHelp);                               /* add extra admin only help to this command */
00033     moduleAddRootHelp(c,myHostServMooRootHelp);                         /* add extra root only help to this command */
00034 
00035     moduleSetHostHelp(myHostServHelp);                                          /* add us to the .hs help list */
00036 
00037     status = moduleAddCommand(HOSTSERV, c, MOD_HEAD);                   /* Add the command to the HOSTSERV cmd table */
00038 
00039     /* Check if we have any argv's */
00040     if(argc>0) {
00041         /* we do, the first will be the nick of the person modload'ing us */
00042         /* or NULL if we were auto-loaded */
00043         if(argv[0]) {
00044                 alog("hs_moo was modloaded by: [%s]",argv[0]);
00045         } else {
00046                 alog("hs_moo was automatically loaded by anope");
00047         }
00048     }
00049     alog("hs_moo.so: Add Command 'moo' Status: %d",status);                     /* Log the command being added */
00050          
00051     moduleAddCallback("test",time(NULL)+dotime("15s"),test,0,NULL);             /* set a call-back function to exec in 3 mins time */
00052     moduleDelCallback("test");
00053     moduleAddAuthor(AUTHOR);                                                            /* tell Anope about the author */
00054     moduleAddVersion(VERSION);                                                          /* Tell Anope about the verison */
00055 
00056     if(status!=MOD_ERR_OK) {
00057         return MOD_STOP;
00058     }
00059     return MOD_CONT;
00060 }
00061 
00062 int hs_moo_show(User * u)
00063 {
00064     notice(s_HostServ, u->nick, "MOO! - This command was loaded via a module!");        /* Just notice the user */
00065     return MOD_STOP;                                                                            /* MOD_STOP means we will NOT pass control back to other */
00066 }                                                                                                               /* modules waiting to handle the /hs moo command! */
00067 
00068 int test(int argc, char **argv) {
00069         alog("CallBack from hs_moo with %d paramaters",argc);
00070         return MOD_CONT;
00071 }
00072 
00073 void AnopeFini(void)
00074 {
00075   /* module is unloading */
00076 }
00077 
00078 /***************************************************************************************************************************************/
00079 /* The code below here shows various ways of dealing with the module help system                                                      */
00080 /***************************************************************************************************************************************/
00081 
00082 void myHostServHelp(User *u) {
00083         notice(s_HostServ,u->nick, "    MOO         Moo's at the user!");               /* this will appear in the help list */
00084 }
00085 
00086 int myHostServMooHelp(User *u) {
00087         notice(s_HostServ,u->nick,"Syntax: Moo");                                     /* this will be sent to everyone who does /msg hostserv help moo */
00088         notice(s_HostServ,u->nick,"This command is an example provided");
00089         notice(s_HostServ,u->nick,"by the Anope development team.");
00090         return MOD_CONT;                                                                                /* allow any other module's with help for /hs moo to run */
00091 }
00092 
00093 int myHostServMooRootHelp(User *u) {                                                            /* this will only be sent to ROOTS ONLY who /msg hostserv moo */
00094         myHostServMooAdminHelp(u);                                                              /* this line lets us show roots the ADMIN help as well as the root help */
00095         notice(s_HostServ,u->nick,"Only roots will see this part of the help");
00096         return MOD_CONT;
00097 }
00098 
00099 int myHostServMooAdminHelp(User *u) {                                                   /* this will only be sent to ADMINS ONLY who /msg hostserv moo */
00100         myHostServMooOperHelp(u);                                                               /* this line lets us show admins the OPER help as well as the admin help */
00101         notice(s_HostServ,u->nick,"Only admins will see this part of the help");
00102         notice(s_HostServ,u->nick,"why not visit us on www.anope.org ?");
00103         return MOD_CONT;
00104 }
00105 
00106 int myHostServMooOperHelp(User *u) {                                                            /* this will only be sent to OPERS ONLY who /msg hostserv moo */
00107         notice(s_HostServ,u->nick,"Only opers will see this part of the help");
00108         notice(s_HostServ,u->nick,"for more help/support with modules");
00109         notice(s_HostServ,u->nick,"visit us on irc.anope.org #anope! :)");
00110         return MOD_CONT;
00111 }
00112 
00113 int myHostServMooRegHelp(User *u) {                                                             /* this will only be sent to REGULAR USERS ONLY who /msg hostserv moo */
00114         notice(s_HostServ,u->nick,"Only non-opers will see this part of the help");
00115         notice(s_HostServ,u->nick,"as we've left it hidden from opers");
00116         return MOD_CONT;
00117 }
00118 
00119 /* EOF */

Generated on Sun Oct 5 09:06:56 2008 for Anope by  doxygen 1.5.7.1