xbot/mods/hello/hello.c

45 lines
967 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>
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-16 22:03:20 -08:00
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);
}
2024-02-12 23:22:10 -08:00
MY_API void mod_init()
{
2024-02-17 00:21:22 -08:00
register_module("hello", "Aaron Blakely", "v0.05", "Test module");
2024-02-16 22:03:20 -08:00
add_handler(PRIVMSG_CHAN, hello);
add_handler(JOIN, hello_join);
2024-02-12 23:22:10 -08:00
}
MY_API void mod_unload()
{
2024-02-17 00:21:22 -08:00
unregister_module("hello");
del_handler(PRIVMSG_CHAN, hello);
2024-02-16 22:03:20 -08:00
del_handler(JOIN, hello_join);
}