bs_say.c

Go to the documentation of this file.
00001 /* BotServ core functions
00002  *
00003  * (C) 2003-2007 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: bs_say.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_say(User * u);
00019 void myBotServHelp(User * u);
00020 
00027 int AnopeInit(int argc, char **argv)
00028 {
00029     Command *c;
00030 
00031     moduleAddAuthor("Anope");
00032     moduleAddVersion("$Id: bs_say.c 1265 2007-08-26 15:33:06Z geniusdex $");
00033     moduleSetType(CORE);
00034     c = createCommand("SAY", do_say, NULL, BOT_HELP_SAY, -1, -1, -1, -1);
00035     moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
00036 
00037     moduleSetBotHelp(myBotServHelp);
00038 
00039     return MOD_CONT;
00040 }
00041 
00045 void AnopeFini(void)
00046 {
00047 
00048 }
00049 
00050 
00051 
00056 void myBotServHelp(User * u)
00057 {
00058     notice_lang(s_BotServ, u, BOT_HELP_CMD_SAY);
00059 }
00060 
00066 int do_say(User * u)
00067 {
00068     ChannelInfo *ci;
00069 
00070     char *chan = strtok(NULL, " ");
00071     char *text = strtok(NULL, "");
00072 
00073     if (!chan || !text)
00074         syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX);
00075     else if (!(ci = cs_findchan(chan)))
00076         notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
00077     else if (ci->flags & CI_VERBOTEN)
00078         notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
00079     else if (!ci->bi)
00080         notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
00081     else if (!ci->c || ci->c->usercount < BSMinUsers)
00082         notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name);
00083     else if (!check_access(u, ci, CA_SAY))
00084         notice_lang(s_BotServ, u, ACCESS_DENIED);
00085     else {
00086         if (text[0] != '\001') {
00087             anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", text);
00088             ci->bi->lastmsg = time(NULL);
00089             if (logchan && LogBot)
00090                 anope_cmd_privmsg(ci->bi->nick, LogChannel,
00091                                   "SAY %s %s %s", u->nick, ci->name, text);
00092         } else {
00093             syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX);
00094         }
00095     }
00096     return MOD_CONT;
00097 }

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