Code:
#include <cstring>
#include <string>
#include <fstream>
#include "IRC.h"
int triggers(char*params,irc_reply_data*hostd,void*conn);
int main()
{
IRC conn;
conn.hook_irc_command("PRIVMSG",&triggers);
conn.start("irc.phoenixradio.org",6667,"Cherilyn","Major_Small","Squishy","");
conn.privmsg("nickserv","identify **********");
conn.join("#Tech");
conn.join("#irpg");
conn.join("#John");
conn.privmsg("irpg-bot","login Major_Small **********");
conn.message_loop();
return 0;
}
int triggers(char*params,irc_reply_data*hostd,void*conn)
{
IRC* irc_conn=(IRC*)conn;
if(strcmp(hostd->target,"#Tech"))
{
return 0;
}
if(!strcmp(params,":!triggers"))
{
std::fstream file("triggers.dat");
std::string trigger;
std::string desc;
std::string line;
irc_conn->notice(hostd->nick,"\002\00315Here's a list of triggers I provide in this channel:\002\003");
while(file>>trigger)
{
getline(file,desc,'\n');
line="\002\0037"+trigger+"\002\00314"+desc+"\003";
irc_conn->notice(hostd->nick,line.c_str());
}
irc_conn->notice(hostd->nick,"\002\00315If you have any questions about me or my triggers, contact Major_Small\002\003");
file.close();
}
else if(!strcmp(params,":!new"))
{
irc_conn->notice(hostd->nick,"\00314Welcome. Please register your name with nickserv by typing \0037/msg nickserv register <password> <email> \00314. If you're using the Java Chat and haven't taken a name, Please do so before registering by typing \0037/nick <newnick>\003");
}
else if(!strcmp(params,":!languages"))
{
std::fstream file("languages.dat");
std::string line;
getline(file,line,'\n');
line="\00314We have people who can help you with "+line+" and more";
irc_conn->notice(hostd->nick,line.c_str());
}
else if(!strcmp(params,":!paste"))
{
irc_conn->notice(hostd->nick,"\00314Use \0037http://rafb.net/paste \00314to paste your code\003");
}
else if(!strcmp(params,":!userlist"))
{
std::string founder;
std::string admin;
std::string ops;
std::string hops;
std::string voice;
std::string bots;
std::fstream file("users.dat",std::ios::in);
getline(file,founder,'\n');
getline(file,admin,'\n');
getline(file,ops,'\n');
getline(file,hops,'\n');
getline(file,voice,'\n');
getline(file,bots,'\n');
file.close();
irc_conn->notice(hostd->nick,"\002\00315Here's a list of the users with access levels on #Tech:\003");
founder="\002\0037Founder:\002 \00314"+founder+";\003";
irc_conn->notice(hostd->nick,founder.c_str());
admin= "\002\0037Admin:\002 \00314"+admin+";\003";
irc_conn->notice(hostd->nick,admin.c_str());
ops= "\002\0037Operators:\002 \00314"+ops+";\003";
irc_conn->notice(hostd->nick,ops.c_str());
hops= "\002\0037Helper-Operators:\002 \00314"+hops+";\003";
irc_conn->notice(hostd->nick,hops.c_str());
voice= "\002\0037Voiced Users:\002 \00314"+voice+";\003";
irc_conn->notice(hostd->nick,voice.c_str());
bots= "\002\0037Bots:\002 \00314"+bots+";\003";
irc_conn->notice(hostd->nick,bots.c_str());
irc_conn->notice(hostd->nick,"\002\00315If you're not on this list, see !new. If you've registered and haven't been given an access level, ask Major_Small. If you've been given an access level but still aren't in this list, just wait until you're added\003");
}
else if(!strcmp(params,":!channels"))
{
std::fstream file("channels.dat",std::ios::in);
std::string chan;
std::string desc;
irc_conn->notice(hostd->nick,"\002\00315This is list of other channels on our network you may also find interesting:\002\003");
while(file>>chan)
{
getline(file,desc,'\n');
chan="\002\0037"+chan+"\002\00314"+desc+"\003";
irc_conn->notice(hostd->nick,chan.c_str());
}
irc_conn->notice(hostd->nick,"\002\00315Please Enjoy your time on the network. If you have another channel you'd like to add, Contact Major_Small\002\003");
}
return 0;
}