2015-04-18 15:51:15 +00:00
|
|
|
#include "irc.h"
|
|
|
|
#include "events.h"
|
|
|
|
#include "module.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2024-02-13 07:22:10 +00:00
|
|
|
#include <string.h>
|
2015-04-18 15:51:15 +00:00
|
|
|
|
2024-02-16 21:28:11 +00:00
|
|
|
MY_API void up(struct irc_conn *bot, char *user, char *host, char *chan, char *text)
|
2015-04-18 15:51:15 +00:00
|
|
|
{
|
|
|
|
char buf[100];
|
|
|
|
FILE* file;
|
|
|
|
|
2024-02-16 21:28:11 +00:00
|
|
|
printf("dbug up called: %s!%s %s\n", user, host, text);
|
2024-02-13 07:22:10 +00:00
|
|
|
|
2015-04-18 15:51:15 +00:00
|
|
|
if (!strcmp(text, "!uptime"))
|
|
|
|
{
|
|
|
|
file = popen("uptime", "r");
|
|
|
|
fgets(buf, 100, file);
|
|
|
|
pclose(file);
|
|
|
|
|
|
|
|
irc_privmsg(bot, chan, "%s", buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-02-13 12:07:59 +00:00
|
|
|
MY_API void mod_init()
|
2015-04-18 15:51:15 +00:00
|
|
|
{
|
2024-02-17 08:21:22 +00:00
|
|
|
register_module("uptime", "Aaron Blakely", "v0.1", "Uptime module");
|
2024-02-13 12:07:59 +00:00
|
|
|
printf("installing up handler\n");
|
2015-04-18 15:51:15 +00:00
|
|
|
add_handler(PRIVMSG_CHAN, up);
|
2024-02-13 07:22:10 +00:00
|
|
|
}
|
2024-02-13 23:47:20 +00:00
|
|
|
|
|
|
|
MY_API void mod_unload()
|
|
|
|
{
|
2024-02-17 08:21:22 +00:00
|
|
|
unregister_module("uptime");
|
2024-02-13 23:47:20 +00:00
|
|
|
printf("unloading up handler\n");
|
|
|
|
del_handler(PRIVMSG_CHAN, up);
|
|
|
|
}
|