remind demo
This commit is contained in:
parent
2a28930a50
commit
90b9baaa18
43
src/main.c
43
src/main.c
@ -26,8 +26,9 @@
|
||||
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "api.h"
|
||||
|
||||
irc_session_t * session;
|
||||
irc_session_t * session = NULL;
|
||||
irc_callbacks_t callbacks;
|
||||
|
||||
char * get_username(const char * origin)
|
||||
@ -83,38 +84,50 @@ event_channel(irc_session_t * session,
|
||||
(void) channel;
|
||||
(void) message;
|
||||
|
||||
char * swp = get_username(origin);
|
||||
msg_wrapper("%s, you are a faggot for this opinion.", swp);
|
||||
free(swp);
|
||||
if(!strcmp(message, "!remind")){
|
||||
msg_wrapper("%s", remind("#/g/chad"));
|
||||
}
|
||||
//char * swp = get_username(origin);
|
||||
//msg_wrapper("%s, you are a faggot for this opinion.", swp);
|
||||
//free(swp);
|
||||
}
|
||||
|
||||
int
|
||||
init(void)
|
||||
{
|
||||
if(api_init())
|
||||
{ ERR(DB_ERROR, "Error initializing database."); }
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
callbacks.event_connect = event_connect;
|
||||
callbacks.event_channel = event_channel;
|
||||
|
||||
session = irc_create_session(&callbacks);
|
||||
if (!session)
|
||||
{ ERR(1, "Error creating IRC session"); }
|
||||
{ ERR(IRC_ERROR, "Error creating IRC session"); }
|
||||
irc_connect(session, SERVER, PORT, 0, USERNAME, USERNAME, USERNAME);
|
||||
if (irc_run(session) != 0)
|
||||
{ ERR(1, "Error running IRC session\nNo net?"); }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rope(int r){
|
||||
if(session){ irc_destroy_session(session); }
|
||||
api_rope();
|
||||
|
||||
exit(r);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc,
|
||||
char ** argv)
|
||||
{
|
||||
if(!init())
|
||||
{
|
||||
while(1)
|
||||
{}
|
||||
irc_destroy_session(session);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if(init())
|
||||
{ return 1; }
|
||||
|
||||
if (irc_run(session) != 0)
|
||||
{ ERR(1, "Error running IRC session\nNo net?"); }
|
||||
|
||||
rope(0);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user