void bahamut::SJoin::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Anope::string modes; if (params.size() >= 4) for (unsigned i = 2; i < params.size(); ++i) modes += " " + params[i]; if (!modes.empty()) modes.erase(modes.begin()); std::list<rfc1459::Join::SJoinUser> users; /* For some reason, bahamut will send a SJOIN from the user joining a channel * if the channel already existed */ if (source.GetUser()) { rfc1459::Join::SJoinUser sju; sju.second = source.GetUser(); users.push_back(sju); } else { spacesepstream sep(params[params.size() - 1]); Anope::string buf; while (sep.GetToken(buf)) { rfc1459::Join::SJoinUser sju; /* Get prefixes from the nick */ for (char ch; !buf.empty() && (ch = ModeManager::GetStatusChar(buf[0]));) { buf.erase(buf.begin()); sju.first.AddMode(ch); } sju.second = User::Find(buf); if (!sju.second) { Log(LOG_DEBUG) << "SJOIN for non-existent user " << buf << " on " << params[1]; continue; } users.push_back(sju); } } time_t ts = Anope::CurTime; try { ts = convertTo<time_t>(params[0]); } catch (const ConvertException &) { } rfc1459::Join::SJoin(source, params[1], ts, modes, users); }
void Away::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &msg = !params.empty() ? params[0] : ""; EventManager::Get()->Dispatch(&Event::UserAway::OnUserAway, source.GetUser(), msg); if (!msg.empty()) Log(source.GetUser(), "away") << "is now away: " << msg; else Log(source.GetUser(), "away") << "is no longer away"; }
void Join::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *user = source.GetUser(); const Anope::string &channels = params[0]; Anope::string channel; commasepstream sep(channels); while (sep.GetToken(channel)) { /* Special case for /join 0 */ if (channel == "0") { for (User::ChanUserList::iterator it = user->chans.begin(), it_end = user->chans.end(); it != it_end; ) { ChanUserContainer *cc = it->second; Channel *c = cc->chan; ++it; EventManager::Get()->Dispatch(&Event::PrePartChannel::OnPrePartChannel, user, c); cc->chan->DeleteUser(user); EventManager::Get()->Dispatch(&Event::PartChannel::OnPartChannel, user, c, c->name, ""); } continue; } std::list<SJoinUser> users; users.push_back(std::make_pair(ChannelStatus(), user)); Channel *chan = Channel::Find(channel); SJoin(source, channel, chan ? chan->creation_time : Anope::CurTime, "", users); } }
/* :0MCAAAAAB CERTFP 4C62287BA6776A89CD4F8FF10A62FFB35E79319F51AF6C62C674984974FCCB1D */ void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); u->fingerprint = params[0]; Event::OnFingerprint(&Event::Fingerprint::OnFingerprint, u); }
/* * <@po||ux> DukeP: RFC 2813, 4.2.1: the JOIN command on server-server links * separates the modes ("o") with ASCII 7, not space. And you can't see ASCII 7. * * if a user joins a new channel, the ircd sends <channelname>\7<umode> */ void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override { User *user = source.GetUser(); size_t pos = params[0].find('\7'); Anope::string channel, modes; if (pos != Anope::string::npos) { channel = params[0].substr(0, pos); modes = '+' + params[0].substr(pos+1, params[0].length()) + " " + user->nick; } else { channel = params[0]; } std::vector<Anope::string> new_params; new_params.push_back(channel); Message::Join::Run(source, new_params); if (!modes.empty()) { Channel *c = Channel::Find(channel); if (c) c->SetModesInternal(source, modes); } }
/* :0MCAAAAAB CERTFP 4C62287BA6776A89CD4F8FF10A62FFB35E79319F51AF6C62C674984974FCCB1D */ void hybrid::CertFP::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.GetUser(); u->fingerprint = params[0]; EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u); }
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 Quit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &reason = params[0]; User *user = source.GetUser(); Log(user, "quit") << "quit (Reason: " << (!reason.empty() ? reason : "no reason") << ")"; user->Quit(reason); }
// Received: :DukeP TOPIC #anope :test void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override { Channel *c = Channel::Find(params[0]); if (!c) { Log(LOG_DEBUG) << "TOPIC for non-existent channel " << params[0]; return; } c->ChangeTopicInternal(source.GetUser(), source.GetName(), params[1], Anope::CurTime); }
void Invite::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *targ = User::Find(params[0]); Channel *c = Channel::Find(params[1]); if (!targ || targ->server != Me || !c || c->FindUser(targ)) return; EventManager::Get()->Dispatch(&Event::Invite::OnInvite, source.GetUser(), c, targ); }
EventReturn OnChannelModeSet(Channel *c, const MessageSource &source, ChannelMode *mode, const Anope::string ¶m) override { if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && c->ci && c->ci->GetBot() && c->FindUser(c->ci->GetBot())) { ServiceBot *bi = c->ci->GetBot(); Entry ban("BAN", param); if (ban.Matches(bi)) c->RemoveMode(bi, "BAN", param); } return EVENT_CONTINUE; }
void bahamut::Topic::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Channel *c = Channel::Find(params[0]); time_t ts = Anope::CurTime; try { ts = convertTo<time_t>(params[2]); } catch (const ConvertException &) { } if (c) c->ChangeTopicInternal(source.GetUser(), params[1], params[3], ts); }
void Notice::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Anope::string message = params[1]; User *u = source.GetUser(); /* ignore channel notices */ if (!IRCD->IsChannelValid(params[0])) { ServiceBot *bi = ServiceBot::Find(params[0]); if (!bi) return; EventManager::Get()->Dispatch(&Event::BotNotice::OnBotNotice, u, bi, message); } }
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; }
// Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam void ratbox::Encap::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { if (params[1] == "LOGIN" || params[1] == "SU") { User *u = source.GetUser(); NickServ::Account *nc = NickServ::FindAccount(params[2]); if (!nc) return; u->Login(nc); /* Sometimes a user connects, we send them the usual "this nickname is registered" mess (if * their server isn't syncing) and then we receive this.. so tell them about it. */ if (u->server->IsSynced()) u->SendMessage(Config->GetClient("NickServ"), _("You have been logged in as \002%s\002."), nc->GetDisplay().c_str()); } }
void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override { User *u = source.GetUser(); // In a burst, states that the source user is logged in as the account. if (params[1] == "LOGIN" || params[1] == "SU") { NickServ::Account *nc = NickServ::FindAccount(params[2]); if (!nc) return; u->Login(nc); } // Received: :42XAAAAAE ENCAP * CERTFP :3f122a9cc7811dbad3566bf2cec3009007c0868f if (params[1] == "CERTFP") { u->fingerprint = params[2]; EventManager::Get()->Dispatch(&Event::Fingerprint::OnFingerprint, u); } /* * Received: :42X ENCAP * SASL 42XAAAAAH * S PLAIN * Received: :42X ENCAP * SASL 42XAAAAAC * D A * * Part of a SASL authentication exchange. The mode is 'C' to send some data * (base64 encoded), or 'S' to end the exchange (data indicates type of * termination: 'A' for abort, 'F' for authentication failure, 'S' for * authentication success). * * Charybdis only accepts messages from SASL agents; these must have umode +S */ if (params[1] == "SASL" && SASL::sasl && params.size() >= 6) { SASL::Message m; m.source = params[2]; m.target = params[3]; m.type = params[4]; m.data = params[5]; m.ext = params.size() > 6 ? params[6] : ""; SASL::sasl->ProcessMessage(m); } }
void Part::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.GetUser(); const Anope::string &reason = params.size() > 1 ? params[1] : ""; Anope::string channel; commasepstream sep(params[0]); while (sep.GetToken(channel)) { Channel *c = Channel::Find(channel); if (!c || !u->FindChannel(c)) continue; Log(u, c, "part") << "Reason: " << (!reason.empty() ? reason : "No reason"); EventManager::Get()->Dispatch(&Event::PrePartChannel::OnPrePartChannel, u, c); c->DeleteUser(u); EventManager::Get()->Dispatch(&Event::PartChannel::OnPartChannel, u, c, c->name, reason); } }
/* * NICK - NEW * Received: :dev.anope.de NICK DukeP_ 1 ~DukePyro ip-2-201-236-154.web.vodafone.de 1 + :DukePyrolator * Parameters: <nickname> <hopcount> <username> <host> <servertoken> <umode> :<realname> * source = server * params[0] = nick * params[1] = hopcount * params[2] = username/ident * params[3] = host * params[4] = servertoken * params[5] = modes * params[6] = info * * NICK - change * Received: :DukeP_ NICK :test2 * source = oldnick * params[0] = newnick * */ void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override { if (params.size() == 1) { // we have a nickchange source.GetUser()->ChangeNick(params[0]); } else if (params.size() == 7) { // a new user is connecting to the network Server *s = Server::Find(params[4]); if (s == NULL) { Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[4] << "?"; return; } User::OnIntroduce(params[0], params[2], params[3], "", "", s, params[6], Anope::CurTime, params[5], "", NULL); Log(LOG_DEBUG) << "Registered nick \"" << params[0] << "\" on server " << s->GetName() << "."; } else { Log(LOG_DEBUG) << "Received NICK with invalid number of parameters. source = " << source.GetName() << "params[0] = " << params[0] << "params.size() = " << params.size(); } }
/* ** NICK - new ** source = NULL ** parv[0] = nickname ** parv[1] = hopcount ** parv[2] = timestamp ** parv[3] = modes ** parv[4] = username ** parv[5] = hostname ** parv[6] = server ** parv[7] = servicestamp ** parv[8] = IP ** parv[9] = info ** NICK - change ** source = oldnick ** parv[0] = new nickname ** parv[1] = hopcount */ void bahamut::Nick::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { if (params.size() == 10) { Server *s = Server::Find(params[6]); if (s == nullptr) { Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[6] << "?"; return; } NickServ::Nick *na = nullptr; time_t signon = 0, stamp = 0; try { signon = convertTo<time_t>(params[2]); stamp = convertTo<time_t>(params[7]); } catch (const ConvertException &) { } if (signon && signon == stamp && NickServ::service) na = NickServ::service->FindNick(params[0]); User::OnIntroduce(params[0], params[4], params[5], "", params[8], s, params[9], signon, params[3], "", na ? na->GetAccount() : nullptr); } else { User *u = source.GetUser(); if (u) u->ChangeNick(params[0]); } }
/* :0MCAAAAAB NICK newnick 1350157102 */ void hybrid::Nick::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { source.GetUser()->ChangeNick(params[0], convertTo<time_t>(params[1])); }
void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { const Anope::string &receiver = params[0]; Anope::string message = params[1]; User *u = source.GetUser(); if (IRCD->IsChannelValid(receiver)) { Channel *c = Channel::Find(receiver); if (c) { EventManager::Get()->Dispatch(&Event::Privmsg::OnPrivmsg, u, c, message); } } else { /* If a server is specified (nick@server format), make sure it matches * us, and strip it off. */ Anope::string botname = receiver; size_t s = receiver.find('@'); bool nick_only = false; if (s != Anope::string::npos) { Anope::string servername(receiver.begin() + s + 1, receiver.end()); botname = botname.substr(0, s); nick_only = true; if (!servername.equals_ci(Me->GetName())) return; } else if (!IRCD->RequiresID && Config->UseStrictPrivmsg) { ServiceBot *bi = ServiceBot::Find(receiver); if (!bi) return; Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << u->nick; u->SendMessage(bi, _("\"/msg %s\" is no longer supported. Use \"/msg %s@%s\" or \"/%s\" instead."), bi->nick.c_str(), bi->nick.c_str(), Me->GetName().c_str(), bi->nick.c_str()); return; } ServiceBot *bi = ServiceBot::Find(botname, nick_only); if (bi) { if (message[0] == '\1' && message[message.length() - 1] == '\1') { if (message.substr(0, 6).equals_ci("\1PING ")) { Anope::string buf = message; buf.erase(buf.begin()); buf.erase(buf.end() - 1); IRCD->SendCTCP(bi, u->nick, "%s", buf.c_str()); } else if (message.substr(0, 9).equals_ci("\1VERSION\1")) { Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); IRCD->SendCTCP(bi, u->nick, "VERSION 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()); } return; } EventReturn MOD_RESULT = EventManager::Get()->Dispatch(&Event::BotPrivmsg::OnBotPrivmsg, u, bi, message); if (MOD_RESULT == EVENT_STOP) return; bi->OnMessage(u, message); } } return; }