2024-02-13 02:22:10 -05:00
|
|
|
#define MY_DLL_EXPORTS 1
|
|
|
|
|
2024-02-21 09:24:49 -05:00
|
|
|
#include "util.h"
|
2015-03-27 11:44:40 -04:00
|
|
|
#include "irc.h"
|
|
|
|
#include "events.h"
|
2015-04-07 02:56:50 -04:00
|
|
|
#include "module.h"
|
2024-02-21 09:24:49 -05:00
|
|
|
#include "timers.h"
|
2015-03-27 11:44:40 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2024-02-13 02:22:10 -05:00
|
|
|
#include <string.h>
|
2015-03-27 11:44:40 -04:00
|
|
|
|
2024-02-21 09:24:49 -05:00
|
|
|
struct said_hi
|
|
|
|
{
|
|
|
|
int timer_id;
|
|
|
|
int repeat;
|
|
|
|
|
|
|
|
char user[50];
|
|
|
|
char host[150];
|
|
|
|
char chan[70];
|
|
|
|
};
|
|
|
|
|
|
|
|
MY_API void said_h(struct irc_conn *bot, void *data)
|
|
|
|
{
|
|
|
|
struct said_hi *hi = (struct said_hi *)data;
|
|
|
|
|
|
|
|
irc_privmsg(bot, hi->chan, "[timer %d] %d : %s", hi->timer_id, get_timer_repeat(hi->timer_id), hi->user);
|
|
|
|
|
|
|
|
if ((get_timer_repeat(hi->timer_id) + 1) > hi->repeat)
|
|
|
|
{
|
|
|
|
free(hi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-16 16:28:11 -05:00
|
|
|
MY_API void hello(struct irc_conn *bot, char *user, char *host, char *chan, const char *text)
|
2015-03-27 11:44:40 -04:00
|
|
|
{
|
2024-02-21 09:24:49 -05:00
|
|
|
struct said_hi *hi;
|
|
|
|
|
2015-03-27 11:44:40 -04:00
|
|
|
char *buf = (char *)malloc(sizeof(char *) * 500);
|
|
|
|
sprintf(buf, "hi %s", bot->nick);
|
|
|
|
|
|
|
|
if (!strcmp(text, buf))
|
|
|
|
{
|
2024-02-21 09:24:49 -05:00
|
|
|
hi = calloc(1, sizeof(struct said_hi));
|
2024-02-13 02:22:10 -05:00
|
|
|
|
2024-02-21 09:24:49 -05:00
|
|
|
irc_privmsg(bot, chan, "hi %s", user);
|
|
|
|
|
|
|
|
sprintf(hi->user, "%s", user);
|
|
|
|
sprintf(hi->host, "%s", host);
|
|
|
|
sprintf(hi->chan, "%s", chan);
|
|
|
|
|
|
|
|
hi->repeat = 3;
|
|
|
|
hi->timer_id = add_timer(bot, 10, hi->repeat, said_h, hi);
|
2015-03-27 11:44:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
free(buf);
|
|
|
|
}
|
|
|
|
|
2024-02-21 09:24:49 -05:00
|
|
|
|
2024-02-17 01:03:20 -05: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-13 02:22:10 -05:00
|
|
|
MY_API void mod_init()
|
2015-03-27 11:44:40 -04:00
|
|
|
{
|
2024-02-17 03:21:22 -05:00
|
|
|
register_module("hello", "Aaron Blakely", "v0.05", "Test module");
|
2024-02-17 01:03:20 -05:00
|
|
|
add_handler(PRIVMSG_CHAN, hello);
|
|
|
|
add_handler(JOIN, hello_join);
|
2024-02-13 02:22:10 -05:00
|
|
|
}
|
2024-02-13 18:47:20 -05:00
|
|
|
|
|
|
|
MY_API void mod_unload()
|
|
|
|
{
|
2024-02-17 03:21:22 -05:00
|
|
|
unregister_module("hello");
|
2024-02-13 18:47:20 -05:00
|
|
|
del_handler(PRIVMSG_CHAN, hello);
|
2024-02-17 01:03:20 -05:00
|
|
|
del_handler(JOIN, hello_join);
|
2024-02-13 18:47:20 -05:00
|
|
|
}
|