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)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,
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) {

View File

@ -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;