Anope IRC Services  Version 1.8
events.c
Go to the documentation of this file.
1 
9 #include "module.h"
10 
11 #define AUTHOR "Anope"
12 #define VERSION VERSION_STRING
13 
14 int my_nick(char *source, int ac, char **av);
15 int my_save(int argc, char **argv);
16 int do_moo(int argc, char **argv);
17 
18 int AnopeInit(int argc, char **argv)
19 {
20  EvtMessage *msg = NULL;
21  EvtHook *hook = NULL;
22  int status;
23  msg = createEventHandler("NICK", my_nick);
24  status = moduleAddEventHandler(msg);
25 
27  status = moduleAddEventHook(hook);
28 
29 
31  status = moduleAddEventHook(hook);
32 
35  return MOD_CONT;
36 }
37 
38 void AnopeFini(void)
39 {
40  /* unloading */
41 }
42 
43 int my_nick(char *source, int ac, char **av)
44 {
45  alog("Internal Event - nick is %s",av[0]);
46  return MOD_CONT;
47 }
48 
49 int my_save(int argc, char **argv)
50 {
51  if(argc>=1) {
52  if (!stricmp(argv[0], EVENT_START)) {
53  alog("Saving the databases! has started");
54  } else {
55  alog("Saving the databases is complete");
56  }
57  }
58  return MOD_CONT;
59 }
60 
70 int do_moo(int argc, char **argv) {
71  ChannelInfo *ci;
72  if(argc>=3) { /* We need at least 3 arguments */
73  if(stricmp(argv[0],"moo")==0) { /* is it meant for us? */
74  if((ci = cs_findchan(argv[2]))) { /* channel should always exist */
75  anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION moos at %s %c",1,argv[1],1);
76  return MOD_STOP; /* We've dealt with it, don't let others */
77  }
78  }
79  }
80  return MOD_CONT; /* guess it wasn't for us, pass it on */
81 }
82 
#define EVENT_DB_SAVING
Definition: events.h:17
void AnopeFini(void)
Definition: events.c:38
int do_moo(int argc, char **argv)
Definition: events.c:70
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
char name[CHANMAX]
Definition: services.h:654
int my_nick(char *source, int ac, char **av)
Definition: events.c:43
int moduleAddEventHandler(EvtMessage *evm)
Definition: events.c:498
#define MOD_STOP
Definition: modules.h:53
EvtHook * createEventHook(char *name, int(*func)(int argc, char **argv))
Definition: events.c:305
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
#define AUTHOR
Definition: events.c:11
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_CONT
Definition: modules.h:54
#define EVENT_START
Definition: events.h:14
#define EVENT_BOT_FANTASY
Definition: events.h:24
int AnopeInit(int argc, char **argv)
Definition: events.c:18
EvtMessage * createEventHandler(char *name, int(*func)(char *source, int ac, char **av))
Definition: events.c:281
E void anope_cmd_privmsg(char *source, char *dest, const char *fmt,...)
Definition: ircd.c:296
char * nick
Definition: services.h:573
int moduleAddEventHook(EvtHook *evh)
Definition: events.c:528
E ChannelInfo * cs_findchan(const char *chan)
Definition: db-merger.c:2000
int my_save(int argc, char **argv)
Definition: events.c:49
BotInfo * bi
Definition: services.h:699
#define VERSION
Definition: events.c:12