Anope IRC Services  Version 1.8
bs_act.c
Go to the documentation of this file.
1 /* BotServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 static int do_act(User * u);
18 static void myBotServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33  c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -1, -1, -1, -1);
35 
37 
38  return MOD_CONT;
39 }
40 
44 void AnopeFini(void)
45 {
46 
47 }
48 
53 static void myBotServHelp(User * u)
54 {
55  notice_lang(s_BotServ, u, BOT_HELP_CMD_ACT);
56 }
57 
63 static int do_act(User * u)
64 {
65  ChannelInfo *ci;
66 
67  char *chan = strtok(NULL, " ");
68  char *text = strtok(NULL, "");
69 
70  if (!chan || !text)
71  syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX);
72  else if (!(ci = cs_findchan(chan)))
73  notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan);
74  else if (ci->flags & CI_VERBOTEN)
75  notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan);
76  else if (!check_access(u, ci, CA_SAY))
77  notice_lang(s_BotServ, u, ACCESS_DENIED);
78  else if (!ci->bi)
79  notice_help(s_BotServ, u, BOT_NOT_ASSIGNED);
80  else if (!ci->c || ci->c->usercount < BSMinUsers)
81  notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name);
82  else {
83  strnrepl(text, BUFSIZE, "\001", "");
84  anope_cmd_action(ci->bi->nick, ci->name, "%s", text);
85  ci->bi->lastmsg = time(NULL);
87  anope_cmd_privmsg(ci->bi->nick, LogChannel, "ACT %s %s %s",
88  u->nick, ci->name, text);
89  }
90  return MOD_CONT;
91 }
int16 usercount
Definition: services.h:1020
E int LogBot
Definition: extern.h:438
char nick[NICKMAX]
Definition: services.h:875
int AnopeInit(int argc, char **argv)
Definition: bs_act.c:26
E char * s_BotServ
Definition: extern.h:287
E int check_access(User *user, ChannelInfo *ci, int what)
Definition: chanserv.c:1974
#define CI_VERBOTEN
Definition: services.h:725
static int do_act(User *u)
Definition: bs_act.c:63
E int BSMinUsers
Definition: extern.h:422
static void myBotServHelp(User *u)
Definition: bs_act.c:53
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
char name[CHANMAX]
Definition: services.h:654
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
E Channel * findchan(const char *chan)
Definition: channels.c:394
uint32 flags
Definition: services.h:669
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
struct channel_ * c
Definition: services.h:692
Command * c
Definition: ns_recover.c:17
#define BOTSERV
Definition: modules.h:57
E void notice_help(char *source, User *dest, int message,...)
Definition: send.c:220
time_t lastmsg
Definition: services.h:581
#define MOD_CONT
Definition: modules.h:54
void AnopeFini(void)
Definition: bs_act.c:44
MDE void moduleSetBotHelp(void(*func)(User *u))
Definition: modules.c:2114
E int debug
Definition: extern.h:775
E int logchan
Definition: extern.h:777
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
E char * LogChannel
Definition: extern.h:280
E void anope_cmd_privmsg(char *source, char *dest, const char *fmt,...)
Definition: ircd.c:296
char * nick
Definition: services.h:573
E ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
E void anope_cmd_action(char *source, char *dest, const char *fmt,...)
Definition: ircd.c:275
#define CA_SAY
Definition: services.h:766
BotInfo * bi
Definition: services.h:699
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define BUFSIZE
Definition: config.h:47
E char * strnrepl(char *s, int32 size, const char *old, const char *new)
Definition: misc.c:144
#define MOD_UNIQUE
Definition: module.h:11