void Topic::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Channel *c = Channel::Find(params[0]); if (c) c->ChangeTopicInternal(source.GetUser(), source.GetSource(), params[1], Anope::CurTime); return; }
void Time::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { time_t t; time(&t); struct tm *tm = localtime(&t); char buf[64]; strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm); IRCD->SendNumeric(391, source.GetSource(), "%s :%s", Me->GetName().c_str(), buf); return; }
/* XXX We should cache the file somewhere not open/read/close it on every request */ void MOTD::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Server *s = Server::Find(params[0]); if (s != Me) return; FILE *f = fopen(Config->GetBlock("serverinfo")->Get<Anope::string>("motd").c_str(), "r"); if (f) { IRCD->SendNumeric(375, source.GetSource(), ":- %s Message of the Day", s->GetName().c_str()); char buf[BUFSIZE]; while (fgets(buf, sizeof(buf), f)) { buf[strlen(buf) - 1] = 0; IRCD->SendNumeric(372, source.GetSource(), ":- %s", buf); } fclose(f); IRCD->SendNumeric(376, source.GetSource(), ":End of /MOTD command."); } else IRCD->SendNumeric(422, source.GetSource(), ":- MOTD file not found! Please contact your IRC administrator."); }
void Message::Stats::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.GetUser(); switch (params[0][0]) { case 'l': if (u->HasMode("OPER")) { IRCD->SendNumeric(211, source.GetSource(), "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime"); IRCD->SendNumeric(211, source.GetSource(), "%s %d %d %d %d %d %d %ld", Config->Uplinks[Anope::CurrentUplink].host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, static_cast<long>(Anope::CurTime - Anope::StartTime)); } IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]); break; case 'o': case 'O': /* Check whether the user is an operator */ if (!u->HasMode("OPER") && Config->GetBlock("options")->Get<bool>("hidestatso")) IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]); else { for (Oper *o : Serialize::GetObjects<Oper *>()) IRCD->SendNumeric(243, source.GetSource(), "O * * %s %s 0", o->GetName().c_str(), o->GetType()->GetName().replace_all_cs(" ", "_").c_str()); IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]); } break; case 'u': { ::Stats *s = Serialize::GetObject<::Stats *>(); long uptime = static_cast<long>(Anope::CurTime - Anope::StartTime); IRCD->SendNumeric(242, source.GetSource(), ":Services up %d day%s, %02d:%02d:%02d", uptime / 86400, uptime / 86400 == 1 ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60); IRCD->SendNumeric(250, source.GetSource(), ":Current users: %d (%d ops); maximum %d", UserListByNick.size(), OperCount, s ? s->GetMaxUserCount() : 0); IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]); break; } /* case 'u' */ default: IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]); } return; }
void Whois::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = User::Find(params[0]); if (u && u->server == Me) { const ServiceBot *bi = ServiceBot::Find(u->GetUID()); IRCD->SendNumeric(311, source.GetSource(), "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str()); if (bi) IRCD->SendNumeric(307, source.GetSource(), "%s :is a registered nick", bi->nick.c_str()); IRCD->SendNumeric(312, source.GetSource(), "%s %s :%s", u->nick.c_str(), Me->GetName().c_str(), Config->GetBlock("serverinfo")->Get<Anope::string>("description").c_str()); if (bi) IRCD->SendNumeric(317, source.GetSource(), "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), static_cast<long>(Anope::CurTime - bi->lastmsg), static_cast<long>(bi->signon)); IRCD->SendNumeric(318, source.GetSource(), "%s :End of /WHOIS list.", u->nick.c_str()); } else IRCD->SendNumeric(401, source.GetSource(), "%s :No such user.", params[0].c_str()); }
void Version::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str()); }