ircd_catserv.c

Go to the documentation of this file.
00001 
00009 #include "module.h"
00010 #include "catserv_messages.h"
00011 
00012 #define AUTHOR "Anope"
00013 #define VERSION "$Id: ircd_catserv.c 953 2006-01-14 11:36:29Z certus $"
00014 
00015 int my_privmsg(char *source, int ac, char **av);
00016 
00017 void addClient(char *nick, char *realname);
00018 void delClient(void);
00019 void catserv(User * u, char *buf);
00020 
00021 char *s_CatServ = "CatServ";
00022 
00023 int AnopeInit(int argc, char **argv)
00024 {
00025     Message *msg = NULL;
00026     int status;
00027 #ifdef IRC_UNREAL32
00028     if (UseTokens) {
00029      msg = createMessage("!", my_privmsg);
00030     } else {
00031      msg = createMessage("PRIVMSG", my_privmsg);
00032     }
00033 #else
00034     msg = createMessage("PRIVMSG", my_privmsg);
00035 #endif
00036     status = moduleAddMessage(msg, MOD_HEAD);
00037     if (status == MOD_ERR_OK) {
00038         addClient(s_CatServ, "meow!");
00039         addMessageList();
00040     }
00041     moduleAddAuthor(AUTHOR);
00042     moduleAddVersion(VERSION);
00043     alog("ircd_catserv.so: loaded, message status [%d]", status);
00044     return MOD_CONT;
00045 }
00046 
00047 void AnopeFini(void)
00048 {
00049     delClient();
00050 }
00051 
00052 int my_privmsg(char *source, int ac, char **av)
00053 {
00054     User *u;
00055     char *s;
00056 
00057     /* First, some basic checks */
00058     if (ac != 2)
00059         return MOD_CONT;        /* bleh */
00060     if (!(u = finduser(source))) {
00061         return MOD_CONT;
00062     }                           /* non-user source */
00063     if (*av[0] == '#') {
00064         return MOD_CONT;
00065     }
00066     /* Channel message */
00067     /* we should prolly honour the ignore list here, but i cba for this... */
00068     s = strchr(av[0], '@');
00069     if (s) {
00070         *s++ = 0;
00071         if (stricmp(s, ServerName) != 0)
00072             return MOD_CONT;
00073     }
00074     if ((stricmp(av[0], s_CatServ)) == 0) {     /* its for US! */
00075         catserv(u, av[1]);
00076         return MOD_STOP;
00077     } else {                    /* ok it isnt us, let the old code have it */
00078         return MOD_CONT;
00079     }
00080 }
00081 
00082 void addClient(char *nick, char *realname)
00083 {
00084     anope_cmd_bot_nick(nick, "catserv", "meow.meow.land", realname, "+");
00085 }
00086 
00087 void delClient(void)
00088 {
00089     anope_cmd_quit(s_CatServ, "QUIT :Module Unloaded!");
00090 }
00091 
00092 /*****************************************************************************/
00093 /* Main CatServ routine. */
00094 void catserv(User * u, char *buf)
00095 {
00096     char *cmd, *s;
00097 
00098     cmd = strtok(buf, " ");
00099 
00100     if (!cmd) {
00101         return;
00102     } else if (stricmp(cmd, "\1PING") == 0) {
00103         if (!(s = strtok(NULL, "")))
00104             s = "\1";
00105         notice(s_CatServ, u->nick, "\1PING %s", s);
00106     } else if (skeleton) {
00107         notice_lang(s_CatServ, u, SERVICE_OFFLINE, s_CatServ);
00108     } else {
00109         mod_run_cmd(s_CatServ, u, Catserv_cmdTable, cmd);
00110     }
00111 }
00112 

Generated on Sun Dec 30 09:26:50 2007 for Anope by  doxygen 1.5.1-20070107