From c286509a3e2faafd761dd31b78a8bed60245875f Mon Sep 17 00:00:00 2001 From: anon Date: Sat, 16 Dec 2023 00:23:46 +0100 Subject: [PATCH] i fixed... something(?) --- source/bot.h | 31 +++++++++++++++++++++---------- source/main.c | 5 +++-- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/source/bot.h b/source/bot.h index 07b9ad9..046a30b 100644 --- a/source/bot.h +++ b/source/bot.h @@ -20,22 +20,31 @@ void event_connect(irc_session_t * session, (void)origin; (void)params; (void)count; - /* msg ChanServ IDENTIFY? */ + + // XXX: msg ChanServ IDENTIFY? log_notice("IRC connection secured."); irc_cmd_join(session, channel, 0); - ircmsg("TEST"); + char * buffer; + asprintf(&buffer, "Joined destination channel: `%s`.", channel); + log_notice(buffer); + free(buffer); } -void event_channel(irc_session_t * session, - char const * event, - char const * origin, - char const ** params, - unsigned int count) { +void event_privmsg(irc_session_t * session, + const char * event, + const char * origin, + const char ** params, + unsigned int count) { (void)session; (void)event; - (void)origin; (void)count; - /* */ + + char * buffer = (char *)origin; + while (*(buffer++) != '!') { ; } + asprintf(&buffer, "From %.*s:", (int)(buffer - origin)-1, origin); + ircmsg(buffer); + free(buffer); + char const * message = params[1]; ircmsg(message); } @@ -43,7 +52,7 @@ void event_channel(irc_session_t * session, int connect_bot(const char * const server, const short port) { memset(&callbacks, 0, sizeof(callbacks)); callbacks.event_connect = event_connect; - callbacks.event_channel = event_channel; + callbacks.event_privmsg = event_privmsg; session = irc_create_session(&callbacks); if (!session) { @@ -61,6 +70,8 @@ int connect_bot(const char * const server, const short port) { username, username ); + + return 0; } int connection_loop(void) { diff --git a/source/main.c b/source/main.c index 9522814..225d0ea 100644 --- a/source/main.c +++ b/source/main.c @@ -1,4 +1,5 @@ #define PROGRAM_NAME "hibot" +#define _GNU_SOURCE #include "config.inc" @@ -10,7 +11,7 @@ char * port; FILE * log_file; #include "log.h" -//#include "xilight.h" +//#include "syntax.h" #include "bot.h" const char help_message[] = @@ -38,7 +39,7 @@ signed main(int argc, char * * argv) { log_file = stdout; - connect_bot(server, 6665); + connect_bot(server, port_i); connection_loop(); return 0;