/*
* IRCbot module for ZNC.
* Made by Aha2Y.
*/
#include "znc.h"
#include "Chan.h"
#include "User.h"
#include "Modules.h"
#include "ZNCString.h"
#include "Server.h"
#include <sstream>
#include <utility>
using namespace std;
string potato(string orig, string search, string repl)
{
string rep = orig;
size_t f = rep.find(search);
while (f != string::npos)
{
rep.replace(f, search.length(), repl);
f = rep.find(search, f + 1);
}
return rep;
}
class CSampleMod : public CModule {
public:
MODCONSTRUCTOR(CSampleMod) {}
virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage) {
if (sMessage == "uptime") {
PutIRC("PRIVMSG " + Nick.GetNick() + " :Running for: " + uptime + "");
return CONTINUE;
}
};
virtual EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage) {
string uptime = potato(string(CZNC::Get().GetVersion(), "h", "hour")
if (sMessage == "!ping") {
PutIRC("PRIVMSG " + Channel.GetName() + " :" + Nick.GetNick() + ": Pong!");
}
if (sMessage == "!uptime") {
PutIRC("PRIVMSG " + Channel.GetName() + " :Running for: " + CZNC::Get().GetUptime() + "");
}
if (sMessage == "!version") {
PutIRC("PRIVMSG " + Channel.GetName() + " :ZncBot 2.0 - Running on ZNC-" + CZNC::Get().GetVersion() + "");
}
return CONTINUE;
}
};
template<> void TModInfo<CSampleMod>(CModInfo& Info) {
Info.SetWikiPage("IRCbot");
}
MODULEDEFS(CSampleMod, "IRCbot")
{"text":"text","html5":"html","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"lua","bash":"sh","erlang":"erlang","go":"golang","c":"c_cpp","cpp":"c_cpp","diff":"diff","latex":"latex","sql":"sql","xml":"xml","0":"text","abap":"abap","actionscript":"actionscript","actionscript3":"actionscript","ada":"ada","apache":"apache_conf","applescript":"applescript","asm":"assembly_x86","autohotkey":"autohotkey","closure":"closure","cobol":"cobol","coffeescript":"coffee","cpp-winapi":"c_cpp","c_loadrunner":"c_cpp","c_mac":"c_cpp","c_winapi":"c_cpp","csharp":"csharp","d":"d","dart":"dart","dot":"dot","eiffel":"eiffel","fortran":"fortran","groovy":"groovy","haskell":"haskell","haxe":"haxe","ini":"ini","io":"io","java":"java","java5":"java","make":"makefile","matlab":"matlab","mysql":"mysql","objc":"objectivec","ocaml":"ocaml","pascal":"pascal","perl":"perl","perl6":"perl","postgresql":"pgsql","powershell":"powershell","prolog":"prolog","properties":"properties","rails":"ruby","rust":"rust","scala":"scala","scheme":"scheme","smarty":"smarty","tcl":"tcl","vala":"vala","vb":"vbscript","verilog":"verilog","vhdl":"vhdl","yaml":"yaml"}