xbot/mods/hello/hello.c

36 lines
617 B
C
Raw Normal View History

2024-02-12 23:22:10 -08:00
#define MY_DLL_EXPORTS 1
#include "irc.h"
#include "events.h"
2015-04-06 23:56:50 -07:00
#include "module.h"
#include <stdio.h>
#include <stdlib.h>
2024-02-12 23:22:10 -08:00
#include <string.h>
2015-04-08 11:56:32 -07:00
int HANDLER = 0;
2024-02-16 13:28:11 -08:00
MY_API void hello(struct irc_conn *bot, char *user, char *host, char *chan, const char *text)
{
char *buf = (char *)malloc(sizeof(char *) * 500);
sprintf(buf, "hi %s", bot->nick);
if (!strcmp(text, buf))
{
2015-04-18 08:51:15 -07:00
irc_privmsg(bot, chan, "hi %s", user);
2024-02-12 23:22:10 -08:00
printf("%s said hi to me\n", user);
}
free(buf);
}
2024-02-12 23:22:10 -08:00
MY_API void mod_init()
{
2015-04-08 11:56:32 -07:00
HANDLER = add_handler(PRIVMSG_CHAN, hello);
2024-02-12 23:22:10 -08:00
}
MY_API void mod_unload()
{
del_handler(PRIVMSG_CHAN, hello);
}