void OnCTCP(const Flux::string &source, const Flux::vector ¶ms) { Flux::string cmd = params.empty()?"":params[0]; Log(LOG_SILENT) << "Received CTCP " << Flux::Sanitize(cmd) << " from " << source; Log(LOG_TERMINAL) << "\033[22;31mReceived CTCP " << Flux::Sanitize(cmd) << " from " << source << Config->LogColor; if(cmd == "\001VERSION\001") { // for CTCP VERSION reply struct utsname uts; if(uname(&uts) < 0) throw CoreException("uname() Error"); ircproto->notice(source, "\001VERSION Navn-%s %s %s\001", VERSION_FULL, uts.sysname, uts.machine); } if(cmd == "\001TIME\001") { // for CTCP TIME reply ircproto->notice(source,"\001TIME %s\001", do_strftime(time(NULL), true).c_str()); } if(cmd == "\001SOURCE\001") { ircproto->notice(source, "\001SOURCE https://github.com/Justasic/Navn\001"); ircproto->notice(source, "\1SOURCE git://github.com/Justasic/Navn.git\1"); } if(cmd == "\001DCC") ircproto->notice(source, "I do not accept or support DCC connections."); }
void DoList(CommandSource &source, ChannelInfo *ci) { EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg"); if (messages == NULL) { source.Reply(_("Entry message list for \002%s\002 is empty."), ci->name.c_str()); return; } source.Reply(_("Entry message list for \002%s\002:"), ci->name.c_str()); ListFormatter list; list.addColumn("Number").addColumn("Creator").addColumn("Created").addColumn("Message"); for (unsigned i = 0; i < messages->size(); ++i) { EntryMsg &msg = messages->at(i); ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); entry["Creator"] = msg.creator; entry["Created"] = do_strftime(msg.when); entry["Message"] = msg.message; list.addEntry(entry); } std::vector<Anope::string> replies; list.Process(replies); for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); source.Reply(_("End of entry message list.")); }
static NODE * fetch_SYS(NODE *symbol, NODE *subs, void *data) { force_string(subs); if (strcmp(subs->stptr, "time") == 0) return do_strftime(0); return NULL; }
void HandleNumber(unsigned Number) { if (!Number || Number > session_service->GetExceptions().size()) return; Exception *e = session_service->GetExceptions()[Number - 1]; ListFormatter::ListEntry entry; entry["Number"] = stringify(Number); entry["Mask"] = e->mask; entry["By"] = e->who; entry["Created"] = do_strftime(e->time); entry["Limit"] = stringify(e->limit); entry["Reason"] = e->reason; this->list.addEntry(entry); }
void ProcessList(CommandSource &source, const std::vector<Anope::string> ¶ms, ListFormatter &list) { const Anope::string &mask = params.size() > 1 ? params[1] : ""; if (session_service->GetExceptions().empty()) { source.Reply(_("The session exception list is empty.")); return; } if (!mask.empty() && mask.find_first_not_of("1234567890,-") == Anope::string::npos) { class ExceptionListCallback : public NumberList { ListFormatter &list; public: ExceptionListCallback(ListFormatter &_list, const Anope::string &numlist) : NumberList(numlist, false), list(_list) { } void HandleNumber(unsigned Number) { if (!Number || Number > session_service->GetExceptions().size()) return; Exception *e = session_service->GetExceptions()[Number - 1]; ListFormatter::ListEntry entry; entry["Number"] = stringify(Number); entry["Mask"] = e->mask; entry["By"] = e->who; entry["Created"] = do_strftime(e->time); entry["Limit"] = stringify(e->limit); entry["Reason"] = e->reason; this->list.addEntry(entry); } } nl_list(list, mask); nl_list.Process(); } else { for (unsigned i = 0, end = session_service->GetExceptions().size(); i < end; ++i) { Exception *e = session_service->GetExceptions()[i]; if (mask.empty() || Anope::Match(e->mask, mask)) { ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); entry["Mask"] = e->mask; entry["By"] = e->who; entry["Created"] = do_strftime(e->time); entry["Limit"] = stringify(e->limit); entry["Reason"] = e->reason; list.addEntry(entry); } } } if (list.isEmpty()) source.Reply(_("No matching entries on session-limit exception list.")); else { source.Reply(_("Current Session Limit Exception list:")); std::vector<Anope::string> replies; list.Process(replies); for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); } }