os_opernews.c

Go to the documentation of this file.
00001 /* OperServ core functions
00002  *
00003  * (C) 2003-2008 Anope Team
00004  * Contact us at info@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  * $Id: os_opernews.c 1432 2008-09-11 17:33:47Z viper $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 Command *c;
00019 
00020 void myOperServHelp(User * u);
00021 int load_config(void);
00022 int reload_config(int argc, char **argv);
00023 
00030 int AnopeInit(int argc, char **argv)
00031 {
00032     EvtHook *hook;
00033     char buf[BUFSIZE];
00034 
00035     moduleAddAuthor("Anope");
00036     moduleAddVersion("$Id: os_opernews.c 1432 2008-09-11 17:33:47Z viper $");
00037     moduleSetType(CORE);
00038 
00043     c = createCommand("OPERNEWS", do_opernews, is_services_admin,
00044                       NEWS_HELP_OPER, -1, -1, -1, -1);
00045     snprintf(buf, BUFSIZE, "%d", NewsCount),
00046     c->help_param1 = sstrdup(buf);
00047     moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
00048 
00049     moduleSetOperHelp(myOperServHelp);
00050 
00051     hook = createEventHook(EVENT_RELOAD, reload_config);
00052     if (moduleAddEventHook(hook) != MOD_ERR_OK) {
00053         alog("[\002os_opernews\002] Can't hook to EVENT_RELOAD event");
00054         return MOD_STOP;
00055     }
00056 
00057     return MOD_CONT;
00058 }
00059 
00063 void AnopeFini(void)
00064 {
00065     free(c->help_param1);
00066 }
00067 
00068 
00073 void myOperServHelp(User * u)
00074 {
00075     if (is_services_admin(u)) {
00076         notice_lang(s_OperServ, u, OPER_HELP_CMD_OPERNEWS);
00077     }
00078 }
00079 
00083 int reload_config(int argc, char **argv) {
00084     char buf[BUFSIZE];
00085 
00086     if (argc >= 1) {
00087         if (!stricmp(argv[0], EVENT_START)) {
00088             free(c->help_param1);
00089             snprintf(buf, BUFSIZE, "%d", NewsCount),
00090             c->help_param1 = sstrdup(buf);
00091         }
00092     }
00093 
00094     return MOD_CONT;
00095 }
00096 
00097 /* EOF */

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