Compare commits
3 Commits
decbd83003
...
3a108d435e
Author | SHA1 | Date | |
---|---|---|---|
3a108d435e | |||
8e9da42790 | |||
c286509a3e |
36
source/bot.h
36
source/bot.h
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user