bs_act.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_act.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_act(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_act.c 1265 2007-08-26 15:33:06Z geniusdex $");
00033     moduleSetType(CORE);
00034     c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -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 
00054 void myBotServHelp(User * u)
00055 {
00056     notice_lang(s_BotServ, u, BOT_HELP_CMD_ACT);
00057 }
00058 
00064 int do_act(User * u)
00065 {
00066     ChannelInfo *ci;
00067 
00068     char *chan = strtok(NULL, " ");
00069     char *text = strtok(NULL, "");
00070 
00071     if (!chan || !text)
00072         syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX);
00073     else if (!(ci = cs_findchan(chan)))
00074         notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
00075     else if (ci->flags & CI_VERBOTEN)
00076         notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
00077     else if (!ci->bi)
00078         notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
00079     else if (!ci->c || ci->c->usercount < BSMinUsers)
00080         notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name);
00081     else if (!check_access(u, ci, CA_SAY))
00082         notice_lang(s_BotServ, u, ACCESS_DENIED);
00083     else {
00084         strnrepl(text, BUFSIZE, "\001", "");
00085         anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION %s %c", 1,
00086                           text, 1);
00087         ci->bi->lastmsg = time(NULL);
00088         if (logchan && LogBot)
00089             anope_cmd_privmsg(ci->bi->nick, LogChannel, "ACT %s %s %s",
00090                               u->nick, ci->name, text);
00091     }
00092     return MOD_CONT;
00093 }

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