From 17dec0f70d683ffe217173f9de4ad2a92128487c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 10 Aug 2013 12:50:50 -0400 Subject: first commit --- main.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..99f8cad --- /dev/null +++ b/main.cpp @@ -0,0 +1,81 @@ +/* + * File: main.cpp + * Author: hatkirby + * + * Created on August 10, 2013, 12:32 PM + */ + +#include +#include "IRC.h" +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * + */ + +char* hostname, nick, port, password, channel; + +char* _(const char* str) +{ + char* res = new char[strlen(str)+1]; + strcpy(res, str); + return res; +} + +int message(char* params, irc_reply_data* hostd, void* conn) +{ + std::string str(params); + std::string thetime(asctime(gettime())); + thetime = thetime.substr(4,15); + + if (*hostd->target != '#') + { + return 0; + } + + // Examine content of strings + + return 0; +} + +int end_of_motd(char* params, irc_reply_data* hostd, void* conn) +{ + IRC* irc_conn = (IRC*) conn; + irc_conn->privmsg(_("NickServ"), strcat(_("Identify "), password)); + irc_conn->join(channel); + irc_conn->hook_irc_command(_("PRIVMSG"), &message); + + return 0; +} + +void terminate(int param) +{ + exit(1); +} + +int main(int argc, char** argv) +{ + atexit(end_logging); + signal(SIGTERM, terminate); + + YAML::Node config = YAML::LoadFile("config.yml"); + hostname = _(config["hostname"].as().c_str()); + port = _(config["port"].as().c_str()); + nick = _(config["nick"].as().c_str()); + password = _(config["password"].as().c_str()); + channel = _(config["password"].as().c_str()); + + IRC conn; + conn.hook_irc_command("266", &end_of_motd); + conn.start(hostname, port, nick, nick, nick, password); + conn.message_loop(); + + return (EXIT_SUCCESS); +} -- cgit 1.4.1