virtual void OnModCommand(const CString& sCmdLine) { CString sCommand = sCmdLine.Token(0); CString sArgs = sCmdLine.Token(1, true); if (sCommand.Equals("setpass")) { PutModule("Password set to [" + sArgs + "]"); m_sPassword = CBlowfish::MD5(sArgs); } else if (sCommand.Equals("dumpbuff")) { CString sFile; if (DecryptChannel(sArgs, sFile)) { VCString vsLines; VCString::iterator it; sFile.Split("\n", vsLines); for (it = vsLines.begin(); it != vsLines.end(); ++it) { CString sLine(*it); sLine.Trim(); PutModule("[" + sLine + "]"); } } PutModule("//!-- EOF " + sArgs); } else if (sCommand.Equals("replay")) { Replay(sArgs); PutModule("Replayed " + sArgs); } else if (sCommand.Equals("save")) { SaveBufferToDisk(); PutModule("Done."); } else PutModule("Unknown command [" + sCommand + "]"); }
void Timeout() { // The timer will be deleted after this by the event loop if (GetNV("silent_timeouts") != "yes") { PutModule("This module hit a timeout which is possibly a bug."); PutModule("Use \"silent yes\" to disable this message."); PutModule("Last request: " + m_sLastRequest); PutModule("Expected replies: "); for (size_t i = 0; m_pReplies[i].szReply != NULL; i++) { if (m_pReplies[i].bLastResponse) PutModule(m_pReplies[i].szReply + CString(" (last)")); else PutModule(m_pReplies[i].szReply); } } m_pDoing = NULL; m_pReplies = NULL; SendRequest(); }
virtual void OnModCommand( const CString& sCommand ) { CString sCmdName = sCommand.Token(0).AsLower(); if(sCmdName == "set") { CString sInterval = sCommand.Token(1, true); SetInterval(sInterval.ToInt()); if(m_uiInterval == 0) PutModule("AntiIdle is now turned off."); else PutModule("AntiIdle is now set to " + CString(m_uiInterval) + " seconds."); } else if(sCmdName == "off") { SetInterval(0); PutModule("AntiIdle is now turned off"); } else if(sCmdName == "show") { if(m_uiInterval == 0) PutModule("AntiIdle is turned off."); else PutModule("AntiIdle is set to " + CString(m_uiInterval) + " seconds."); } else { PutModule("Commands: set, off, show"); } }
virtual EModRet OnBroadcast(CString& sMessage) { PutModule("------ [" + sMessage + "]"); sMessage = "======== [" + sMessage + "] ========"; return CONTINUE; }
void SendSkypeMsgToIRC(const CReceivedSkypeMsg *a_msg) { CString l_msgBuffer; if(a_msg->timestamp < time(0) - 120 && !a_msg->edited) { char l_timeBuf[100]; strftime(l_timeBuf, 100, "[%a %H:%M:%S] ", localtime(&a_msg->timestamp)); l_msgBuffer = l_timeBuf; } if(!a_msg->edited) { if(a_msg->type == "EMOTED") { l_msgBuffer += a_msg->fromDispname + " "; } else { l_msgBuffer += "<" + a_msg->fromDispname + "> "; } l_msgBuffer += a_msg->body; } else { char l_timeBuf[100]; strftime(l_timeBuf, 100, "%H:%M:%S", localtime(&a_msg->timestamp)); if(a_msg->body == "[deleted]") { l_msgBuffer += "(" + a_msg->fromDispname + " deleted their message from " + CString(l_timeBuf) + ")"; } else { l_msgBuffer += a_msg->fromDispname + " edited their message from " + CString(l_timeBuf) + ": " + a_msg->body; } } l_msgBuffer.Replace("\r", ""); l_msgBuffer.Replace("\n", " "); for(MCString::iterator it = m_chanNameMap.begin(); it != m_chanNameMap.end(); it++) { if(it->second.Equals(a_msg->chatName)) { std::wstring l_buffer = Utf8ToWide(l_msgBuffer); std::wstring l_line; CString l_utfLine; do { l_line = l_buffer.substr(0, 400); l_buffer.erase(0, 400); if(!l_buffer.empty()) { l_line += L"..."; l_buffer = L"..." + l_buffer; } l_utfLine = WideToUtf8(l_line); PutIRC("PRIVMSG " + it->first + " :" + l_utfLine); PutUser(":" + m_pUser->GetIRCNick().GetNick() + "!x@y PRIVMSG " + it->first + " :" + l_utfLine); } while(!l_buffer.empty()); return; } } PutModule("WARNING: Group chat " + a_msg->chatName + " not mapped to any channel. A message has been lost."); }
virtual void OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange) { PutModule(((bNoChange) ? "[0] [" : "[1] [") + OpNick.GetNick() + "] devoiced [" + Nick.GetNick() + "] on [" + Channel.GetName() + "]"); }
virtual void OnIRCDisconnected() { PutModule("You got disconnected BoyOh."); }
void ShowSocks(bool bShowHosts) { CSockManager& m = CZNC::Get().GetManager(); if (!m.size()) { PutStatus("You have no open sockets."); return; } std::priority_queue<CSocketSorter> socks; for (unsigned int a = 0; a < m.size(); a++) { socks.push(m[a]); } CTable Table; Table.AddColumn("Name"); Table.AddColumn("Created"); Table.AddColumn("State"); #ifdef HAVE_LIBSSL Table.AddColumn("SSL"); #endif Table.AddColumn("Local"); Table.AddColumn("Remote"); while (!socks.empty()) { Csock* pSocket = socks.top().GetSock(); socks.pop(); Table.AddRow(); switch (pSocket->GetType()) { case Csock::LISTENER: Table.SetCell("State", "Listen"); break; case Csock::INBOUND: Table.SetCell("State", "Inbound"); break; case Csock::OUTBOUND: if (pSocket->IsConnected()) Table.SetCell("State", "Outbound"); else Table.SetCell("State", "Connecting"); break; default: Table.SetCell("State", "UNKNOWN"); break; } unsigned long long iStartTime = pSocket->GetStartTime(); time_t iTime = iStartTime / 1000; Table.SetCell("Created", FormatTime("%Y-%m-%d %H:%M:%S", iTime)); #ifdef HAVE_LIBSSL if (pSocket->GetSSL()) { Table.SetCell("SSL", "Yes"); } else { Table.SetCell("SSL", "No"); } #endif Table.SetCell("Name", pSocket->GetSockName()); CString sVHost; if (bShowHosts) { sVHost = pSocket->GetBindHost(); } if (sVHost.empty()) { sVHost = pSocket->GetLocalIP(); } Table.SetCell("Local", sVHost + " " + CString(pSocket->GetLocalPort())); CString sHost; if (!bShowHosts) { sHost = pSocket->GetRemoteIP(); } // While connecting, there might be no ip available if (sHost.empty()) { sHost = pSocket->GetHostName(); } u_short uPort; // While connecting, GetRemotePort() would return 0 if (pSocket->GetType() == Csock::OUTBOUND) { uPort = pSocket->GetPort(); } else { uPort = pSocket->GetRemotePort(); } if (uPort != 0) { Table.SetCell("Remote", sHost + " " + CString(uPort)); } else { Table.SetCell("Remote", sHost); } } PutModule(Table); return; }
void SetFile(const CString& sLine) { SetNV("File", sLine.Token(1, true)); PutModule("File has been set to: " + GetNV("File")); }
void SetCommand(const CString& sLine) { SetNV("Password", sLine.Token(1, true)); PutModule("Password set"); }
virtual EModRet OnRaw(CString& sLine) { PutModule("IRC -> [" + sLine + "]"); return CONTINUE; }
virtual void OnModCommand(const CString& sCommand) { if (!GetUser()->IsAdmin()) { PutModule("Access denied"); return; } CString sCmd = sCommand.Token(0); if (sCmd.Equals("target")) { CString sArg = sCommand.Token(1, true); CString sTarget; CString sMessage; LogMode mode; if (sArg.Equals("file")) { sTarget = "file"; sMessage = "Now only logging to file"; mode = LOG_TO_FILE; } #ifndef _WIN32 else if (sArg.Equals("syslog")) { sTarget = "syslog"; sMessage = "Now only logging to syslog"; mode = LOG_TO_SYSLOG; } else if (sArg.Equals("both")) { sTarget = "both"; sMessage = "Now logging to file and syslog"; mode = LOG_TO_BOTH; } #endif else { PutModule("Unknown target"); return; } Log(sMessage); SetNV("target", sTarget); m_eLogMode = mode; PutModule(sMessage); } else if (sCmd.Equals("show")) { CString sTarget; #ifndef _WIN32 switch (m_eLogMode) { case LOG_TO_FILE: sTarget = "file"; break; case LOG_TO_SYSLOG: sTarget = "syslog"; break; case LOG_TO_BOTH: sTarget = "both, file and syslog"; break; } #else sTarget = "file"; #endif PutModule("Logging is enabled for " + sTarget); if (m_eLogMode != LOG_TO_SYSLOG) PutModule("Log file will be written to [" + m_sLogFile + "]"); } else #ifndef _WIN32 PutModule("Commands: show, target <file|syslog|both>"); #else PutModule("Commands: Only logging to a file is supported on Win32."); #endif }
void GetFile(const CString& sLine) { PutModule(t_f("File is set to: {1}")(GetNV("File"))); }
void OnShowCommand(const CString& sCommand) { PutModule("Current limit is " + CString(m_iThresholdMsgs) + " CTCPs " "in " + CString(m_iThresholdSecs) + " secs"); }
void ViewCommandsCommand(const CString& sLine) { PutModule("IDENTIFY " + GetNV("IdentifyCmd")); }
virtual void OnRawMode(const CNick& OpNick, CChan& Channel, const CString& sModes, const CString& sArgs) { PutModule("* " + OpNick.GetNick() + " sets mode: " + sModes + " " + sArgs + " (" + Channel.GetName() + ")"); }
void Execute(const CString& sCommand) { OnIRCConnected(); PutModule(t_s("perform commands sent")); }
void SetNSNameCommand(const CString& sLine) { SetNV("NickServName", sLine.Token(1, true)); PutModule("NickServ name set"); }
virtual void OnModCommand(const CString& sCommand) { CString sCmdName = sCommand.Token(0).AsLower(); if (sCmdName == "add") { CString sPerf = sCommand.Token(1, true); if (sPerf.empty()) { PutModule("Usage: add <command>"); return; } if (sPerf.Left(1) == "/") sPerf.LeftChomp(); if (sPerf.Token(0).Equals("MSG")) { sPerf = "PRIVMSG " + sPerf.Token(1, true); } if ((sPerf.Token(0).Equals("PRIVMSG") || sPerf.Token(0).Equals("NOTICE")) && sPerf.Token(2).Left(1) != ":") { sPerf = sPerf.Token(0) + " " + sPerf.Token(1) + " :" + sPerf.Token(2, true); } m_vPerform.push_back(sPerf); PutModule("Added!"); Save(); } else if (sCmdName == "del") { u_int iNum = sCommand.Token(1, true).ToUInt(); if (iNum > m_vPerform.size() || iNum <= 0) { PutModule("Illegal # Requested"); return; } else { m_vPerform.erase(m_vPerform.begin() + iNum - 1); PutModule("Command Erased."); } Save(); } else if (sCmdName == "list") { int i = 1; CString sExpanded; for (VCString::iterator it = m_vPerform.begin(); it != m_vPerform.end(); it++, i++) { sExpanded = GetUser()->ExpandString(*it); if (sExpanded != *it) PutModule(CString(i) + ": " + *it + " (" + sExpanded + ")"); else PutModule(CString(i) + ": " + *it); } PutModule(" -- End of List"); } else if (sCmdName == "execute") { OnIRCConnected(); PutModule("perform commands sent"); } else if (sCmdName == "swap") { u_int iNumA = sCommand.Token(1).ToUInt(); u_int iNumB = sCommand.Token(2).ToUInt(); if (iNumA > m_vPerform.size() || iNumA <= 0 || iNumB > m_vPerform.size() || iNumB <= 0) { PutModule("Illegal # Requested"); } else { std::iter_swap(m_vPerform.begin() + (iNumA - 1), m_vPerform.begin() + (iNumB - 1)); PutModule("Commands Swapped."); Save(); } } else { PutModule("Commands: add <command>, del <nr>, list, execute, swap <nr> <nr>"); } }
virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0).AsUpper(); if (sCommand.Equals("HELP")) { PutModule("Commands are: ListUsers, AddChans, DelChans, AddUser, DelUser"); } else if (sCommand.Equals("TIMERS")) { ListTimers(); } else if (sCommand.Equals("ADDUSER") || sCommand.Equals("DELUSER")) { CString sUser = sLine.Token(1); CString sHost = sLine.Token(2); CString sKey = sLine.Token(3); if (sCommand.Equals("ADDUSER")) { if (sHost.empty()) { PutModule("Usage: " + sCommand + " <user> <hostmask> <key> [channels]"); } else { CAutoOpUser* pUser = AddUser(sUser, sKey, sHost, sLine.Token(4, true)); if (pUser) { SetNV(sUser, pUser->ToString()); } } } else { DelUser(sUser); DelNV(sUser); } } else if (sCommand.Equals("LISTUSERS")) { if (m_msUsers.empty()) { PutModule("There are no users defined"); return; } CTable Table; Table.AddColumn("User"); Table.AddColumn("Hostmask"); Table.AddColumn("Key"); Table.AddColumn("Channels"); for (map<CString, CAutoOpUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); it++) { Table.AddRow(); Table.SetCell("User", it->second->GetUsername()); Table.SetCell("Hostmask", it->second->GetHostmask()); Table.SetCell("Key", it->second->GetUserKey()); Table.SetCell("Channels", it->second->GetChannels()); } PutModule(Table); } else if (sCommand.Equals("ADDCHANS") || sCommand.Equals("DELCHANS")) { CString sUser = sLine.Token(1); CString sChans = sLine.Token(2, true); if (sChans.empty()) { PutModule("Usage: " + sCommand + " <user> <channel> [channel] ..."); return; } CAutoOpUser* pUser = FindUser(sUser); if (!pUser) { PutModule("No such user"); return; } if (sCommand.Equals("ADDCHANS")) { pUser->AddChans(sChans); PutModule("Channel(s) added to user [" + pUser->GetUsername() + "]"); } else { pUser->DelChans(sChans); PutModule("Channel(s) Removed from user [" + pUser->GetUsername() + "]"); } SetNV(pUser->GetUsername(), pUser->ToString()); } else { PutModule("Unknown command, try HELP"); } }
void DisableCloneUserCommand(const CString &sLine) { DelNV("CloneUser"); PutModule("Clone user disabled"); }
void GetFormat(const CString& sLine) { PutModule("Format is set to: " + GetNV("Format")); PutModule("Format would be expanded to: " + ExpandString(GetNV("Format"))); }
void GetFile(const CString& sLine) { PutModule("File is set to: " + GetNV("File")); }
virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0); if (sCommand.Equals("ADD")) { CString sChan = sLine.Token(1); if (AlreadyAdded(sChan)) { PutModule(sChan + " is already added"); } else if (Add(sChan)) { PutModule("Added " + sChan + " to list"); } else { PutModule("Usage: Add [!]<#chan>"); } } else if (sCommand.Equals("DEL")) { CString sChan = sLine.Token(1); if (Del(sChan)) PutModule("Removed " + sChan + " from list"); else PutModule("Usage: Del [!]<#chan>"); } else if (sCommand.Equals("LIST")) { CTable Table; Table.AddColumn("Chan"); for (unsigned int a = 0; a < m_vsChans.size(); a++) { Table.AddRow(); Table.SetCell("Chan", m_vsChans[a]); } for (unsigned int b = 0; b < m_vsNegChans.size(); b++) { Table.AddRow(); Table.SetCell("Chan", "!" + m_vsNegChans[b]); } if (Table.size()) { PutModule(Table); } else { PutModule("You have no entries."); } } else if (sCommand.Equals("HELP")) { CTable Table; Table.AddColumn("Command"); Table.AddColumn("Description"); Table.AddRow(); Table.SetCell("Command", "Add"); Table.SetCell("Description", "Add an entry, use !#chan to negate and * for wildcards"); Table.AddRow(); Table.SetCell("Command", "Del"); Table.SetCell("Description", "Remove an entry, needs to be an exact match"); Table.AddRow(); Table.SetCell("Command", "List"); Table.SetCell("Description", "List all entries"); if (Table.size()) { PutModule(Table); } else { PutModule("You have no entries."); } } }
void SetFormat(const CString& sLine) { SetNV("Format", sLine.Token(1, true)); PutModule("Format has been set to: " + GetNV("Format")); PutModule("Format would be expanded to: " + ExpandString(GetNV("Format"))); }
virtual void OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange) { PutModule(((bNoChange) ? "[0] [" : "[1] [") + OpNick.GetNick() + "] set mode [" + Channel.GetName() + ((bAdded) ? "] +" : "] -") + CString(uMode) + " " + Nick.GetNick()); }
virtual EModRet OnUserRaw(CString& sLine) override { PutModule("YOU -> [" + sLine + "]"); return CONTINUE; }
virtual void OnModCommand(const CString& sCommand) { PutModule("This module takes no configuration."); PutModule("Make sure to set KeepBuffer to true, the module is useless otherwise."); }
virtual void OnModCommand(const CString& sCommand) override { PutModule("This module can only be configured through its arguments."); PutModule("The module argument is the number of minutes an IP"); PutModule("is blocked after a failed login."); }
EModRet OnChanCTCP(CNick& Nick, CChan& Channel, CString& sMessage) { if (IsCtcpNotifier(sMessage.Token(0))) PutModule("Replying to CTCP " + sMessage.Token(0) + " by " + Nick.GetNick() + " (" + Nick.GetHostMask() + ") to " + Channel.GetName() + "."); return CONTINUE; }