summaryrefslogtreecommitdiff
path: root/src/modules/events.c
blob: af53a3d405d3fac7800e5ae64d8f17bf0426bc42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
 * Simple module to show the usage of event messages and hooks
 * This module is an example, and has no useful purpose!
 *
 * Please visit http://modules.anope.org for useful modules! 
 *
 **/

#include "module.h"

#define AUTHOR "Anope"
#define VERSION "1.1"

int my_nick(char *source, int ac, char **av);
int my_save(char *message);

int AnopeInit(int argc, char **argv)
{
    EvtMessage *msg = NULL;
    EvtHook    *hook = NULL;
    int status;
    msg = createEventHandler("NICK", my_nick);
    status = moduleAddEventHandler(msg);

    hook = createEventHook(EVENT_DB_SAVING, my_save);
    status = moduleAddEventHook(hook);

    moduleAddAuthor(AUTHOR);
    moduleAddVersion(VERSION);
    return MOD_CONT;
}

void AnopeFini(void)
{
 /* unloading */
}

int my_nick(char *source, int ac, char **av)
{
  alog("Internal Event - nick is %s",av[0]);
  return MOD_CONT;
}

int my_save(char *message)
{
  if (!stricmp(message, EVENT_START)) {
      alog("Saving the databases! has started");
  } else {
      alog("Saving the databases is complete");
  }
  return MOD_CONT;
}