xbot/mods/hello/hello.c
2024-02-17 02:21:22 -06:00

45 lines
967 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>
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))
{
irc_privmsg(bot, chan, "hi %s", user);
printf("%s said hi to me\n", user);
}
free(buf);
}
MY_API void hello_join(struct irc_conn *bot, char *user, char *host, char *chan)
{
printf("%s!%s joined %s\n", user, host, chan);
irc_privmsg(bot, chan, "Hi %s! Welcome to %s", user, chan);
}
MY_API void mod_init()
{
register_module("hello", "Aaron Blakely", "v0.05", "Test module");
add_handler(PRIVMSG_CHAN, hello);
add_handler(JOIN, hello_join);
}
MY_API void mod_unload()
{
unregister_module("hello");
del_handler(PRIVMSG_CHAN, hello);
del_handler(JOIN, hello_join);
}