xbot/mods/hello/hello.c
2024-02-13 17:47:20 -06:00

36 lines
605 B
C
Executable File

#define MY_DLL_EXPORTS 1
#include "irc.h"
#include "events.h"
#include "module.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int HANDLER = 0;
MY_API void hello(struct irc_conn *bot, char *user, char *chan, const char *text)
{
char *buf = (char *)malloc(sizeof(char *) * 500);
sprintf(buf, "hi %s", bot->nick);
if (!strcmp(text, buf))
{
irc_privmsg(bot, chan, "hi %s", user);
printf("%s said hi to me\n", user);
}
free(buf);
}
MY_API void mod_init()
{
HANDLER = add_handler(PRIVMSG_CHAN, hello);
}
MY_API void mod_unload()
{
del_handler(PRIVMSG_CHAN, hello);
}