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 VERSION_STRING
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 if (UseTokens) {
00028 msg = createMessage("!", my_privmsg);
00029 } else {
00030 msg = createMessage("PRIVMSG", my_privmsg);
00031 }
00032 status = moduleAddMessage(msg, MOD_HEAD);
00033 if (status == MOD_ERR_OK) {
00034 addClient(s_CatServ, "meow!");
00035 addMessageList();
00036 }
00037 moduleAddAuthor(AUTHOR);
00038 moduleAddVersion(VERSION);
00039 alog("ircd_catserv.so: loaded, message status [%d]", status);
00040 return MOD_CONT;
00041 }
00042
00043 void AnopeFini(void)
00044 {
00045 delClient();
00046 }
00047
00048 int my_privmsg(char *source, int ac, char **av)
00049 {
00050 User *u;
00051 Uid *ud = NULL;
00052 char *s;
00053
00054
00055 if (ac != 2)
00056 return MOD_CONT;
00057 if (ircd->ts6)
00058 u = find_byuid(source);
00059 if (!u && !(u = finduser(source))) {
00060 return MOD_CONT;
00061 }
00062 if (*av[0] == '#') {
00063 return MOD_CONT;
00064 }
00065
00066
00067 s = strchr(av[0], '@');
00068 if (s) {
00069 *s++ = 0;
00070 if (stricmp(s, ServerName) != 0)
00071 return MOD_CONT;
00072 }
00073 if (ircd->ts6)
00074 ud = find_uid(s_CatServ);
00075 if (stricmp(av[0], s_CatServ) == 0 || (ud && strcmp(av[0], ud->uid) == 0)) {
00076 catserv(u, av[1]);
00077 return MOD_STOP;
00078 } else {
00079 return MOD_CONT;
00080 }
00081 }
00082
00083 void addClient(char *nick, char *realname)
00084 {
00085 anope_cmd_bot_nick(nick, "catserv", "meow.meow.land", realname, "+");
00086 }
00087
00088 void delClient(void)
00089 {
00090 anope_cmd_quit(s_CatServ, "QUIT :Module Unloaded!");
00091 }
00092
00093
00094
00095 void catserv(User * u, char *buf)
00096 {
00097 char *cmd, *s;
00098
00099 cmd = strtok(buf, " ");
00100
00101 if (!cmd) {
00102 return;
00103 } else if (stricmp(cmd, "\1PING") == 0) {
00104 if (!(s = strtok(NULL, "")))
00105 s = "\1";
00106 notice(s_CatServ, u->nick, "\1PING %s", s);
00107 } else if (skeleton) {
00108 notice_lang(s_CatServ, u, SERVICE_OFFLINE, s_CatServ);
00109 } else {
00110 mod_run_cmd(s_CatServ, u, Catserv_cmdTable, cmd);
00111 }
00112 }
00113