Compare commits

...

3 Commits

Author SHA1 Message Date
3a108d435e logical merge 2023-12-16 00:27:56 +01:00
8e9da42790 Merge branch 'master' of https://git.lain.church/anon/hibot 2023-12-16 00:24:15 +01:00
c286509a3e i fixed... something(?) 2023-12-16 00:23:46 +01:00
2 changed files with 29 additions and 14 deletions

View File

@ -20,30 +20,40 @@ 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 const * message = params[1];
ircmsg(message);
char * buffer = (char *)origin;
while (*(buffer++) != '!') { ; }
asprintf(&buffer, "From %.*s:", (int)(buffer - origin)-1, origin);
ircmsg(buffer);
free(buffer);
char * message = strdup(params[1]);
ircmsg(syntax_highlight(message));
free(message);
}
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 +71,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,9 @@ signed main(int argc, char * * argv) {
log_file = stdout;
connect_bot(server, 6665);
syntax_c();
connect_bot(server, port_i);
connection_loop();
return 0;