i fixed... something(?)

This commit is contained in:
anon 2023-12-16 00:23:46 +01:00
parent 649867d5a6
commit c286509a3e
2 changed files with 24 additions and 12 deletions

View File

@ -20,22 +20,31 @@ void event_connect(irc_session_t * session,
(void)origin; (void)origin;
(void)params; (void)params;
(void)count; (void)count;
/* msg ChanServ IDENTIFY? */
// XXX: msg ChanServ IDENTIFY?
log_notice("IRC connection secured."); log_notice("IRC connection secured.");
irc_cmd_join(session, channel, 0); 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, void event_privmsg(irc_session_t * session,
char const * event, const char * event,
char const * origin, const char * origin,
char const ** params, const char ** params,
unsigned int count) { unsigned int count) {
(void)session; (void)session;
(void)event; (void)event;
(void)origin;
(void)count; (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]; char const * message = params[1];
ircmsg(message); ircmsg(message);
} }
@ -43,7 +52,7 @@ void event_channel(irc_session_t * session,
int connect_bot(const char * const server, const short port) { int connect_bot(const char * const server, const short port) {
memset(&callbacks, 0, sizeof(callbacks)); memset(&callbacks, 0, sizeof(callbacks));
callbacks.event_connect = event_connect; callbacks.event_connect = event_connect;
callbacks.event_channel = event_channel; callbacks.event_privmsg = event_privmsg;
session = irc_create_session(&callbacks); session = irc_create_session(&callbacks);
if (!session) { if (!session) {
@ -61,6 +70,8 @@ int connect_bot(const char * const server, const short port) {
username, username,
username username
); );
return 0;
} }
int connection_loop(void) { int connection_loop(void) {

View File

@ -1,4 +1,5 @@
#define PROGRAM_NAME "hibot" #define PROGRAM_NAME "hibot"
#define _GNU_SOURCE
#include "config.inc" #include "config.inc"
@ -10,7 +11,7 @@ char * port;
FILE * log_file; FILE * log_file;
#include "log.h" #include "log.h"
//#include "xilight.h" //#include "syntax.h"
#include "bot.h" #include "bot.h"
const char help_message[] = const char help_message[] =
@ -38,7 +39,7 @@ signed main(int argc, char * * argv) {
log_file = stdout; log_file = stdout;
connect_bot(server, 6665); connect_bot(server, port_i);
connection_loop(); connection_loop();
return 0; return 0;