From f858164deed48f2dcacd5ffc06a55398a54da7e8 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 14 Jul 2011 02:31:12 -0400 Subject: Rewrote how commands are handled within Anope. This allows naming commands and having spaces within command names. --- modules/protocol/bahamut.cpp | 56 +++++------------------------------------ modules/protocol/inspircd-ts6.h | 18 +++++++------ modules/protocol/inspircd11.cpp | 23 +++++++++-------- modules/protocol/inspircd12.cpp | 5 ++-- modules/protocol/inspircd20.cpp | 3 ++- modules/protocol/plexus.cpp | 19 +++++++------- modules/protocol/ratbox.cpp | 17 +++++++------ modules/protocol/unreal.cpp | 15 +++++------ 8 files changed, 61 insertions(+), 95 deletions(-) (limited to 'modules/protocol') diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index ff2cab4d2..ece676f22 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -13,6 +13,7 @@ #include "services.h" #include "modules.h" +#include "oper.h" #include "nickserv.h" IRCDVar myIrcd[] = { @@ -224,7 +225,7 @@ class BahamutIRCdProto : public IRCDProto /* nc_change was = 1, and there is no na->status */ void SendUnregisteredNick(const User *u) { - ircdproto->SendMode(nickserv->Bot(), u, "+d 1"); + ircdproto->SendMode(findbot(Config->NickServ), u, "+d 1"); } /* SERVER */ @@ -247,7 +248,7 @@ class BahamutIRCdProto : public IRCDProto if (!u->Account()) return; - ircdproto->SendMode(nickserv->Bot(), u, "+d %d", u->timestamp); + ircdproto->SendMode(findbot(Config->NickServ), u, "+d %d", u->timestamp); } void SendChannel(Channel *c) @@ -306,7 +307,7 @@ class BahamutIRCdMessage : public IRCdMessage { user->Login(na->nc); if (na->nc->HasFlag(NI_UNCONFIRMED) == false) - user->SetMode(nickserv->Bot(), UMODE_REGISTERED); + user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } else nickserv->Validate(user); @@ -472,49 +473,6 @@ class BahamutIRCdMessage : public IRCdMessage } }; -static bool event_xs(const Anope::string &bot, const Anope::string &source, const std::vector ¶ms) -{ - if (!params.empty() && !bot.empty()) - { - std::vector p; - p.push_back(bot); - p.push_back(params[0]); - return ircdmessage->OnPrivmsg(source, p); - } - - return true; -} - -/* EVENT : OS */ -bool event_os(const Anope::string &source, const std::vector ¶ms) -{ - return event_xs(Config->s_OperServ, source, params); -} - -/* EVENT : NS */ -bool event_ns(const Anope::string &source, const std::vector ¶ms) -{ - return event_xs(Config->s_NickServ, source, params); -} - -/* EVENT : MS */ -bool event_ms(const Anope::string &source, const std::vector ¶ms) -{ - return event_xs(Config->s_MemoServ, source, params); -} - -/* EVENT : HS */ -bool event_hs(const Anope::string &source, const std::vector ¶ms) -{ - return event_xs(Config->s_HostServ, source, params); -} - -/* EVENT : CS */ -bool event_cs(const Anope::string &source, const std::vector ¶ms) -{ - return event_xs(Config->s_ChanServ, source, params); -} - bool event_burst(const Anope::string &source, const std::vector ¶ms) { Server *s = Server::Find(source); @@ -558,7 +516,7 @@ class ChannelModeFlood : public ChannelModeParam class ProtoBahamut : public Module { - Message message_svsmode, message_cs, message_hs, message_ms, message_ns, message_os, message_burst; + Message message_svsmode, message_burst; BahamutIRCdProto ircd_proto; BahamutIRCdMessage ircd_message; @@ -602,9 +560,7 @@ class ProtoBahamut : public Module public: ProtoBahamut(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), - message_svsmode("SVSMODE", OnMode), message_cs("CS", event_cs), message_hs("HS", event_hs), - message_ms("MS", event_ms), message_ns("NS", event_ns), message_os("OS", event_os), - message_burst("BURST", event_burst) + message_svsmode("SVSMODE", OnMode), message_burst("BURST", event_burst) { this->SetAuthor("Anope"); diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h index 54a615aaf..d58e1c987 100644 --- a/modules/protocol/inspircd-ts6.h +++ b/modules/protocol/inspircd-ts6.h @@ -33,7 +33,7 @@ class InspIRCdTS6Proto : public IRCDProto private: void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent) { - User *u = finduser(Config->s_HostServ); + User *u = finduser(Config->HostServ); if (!has_chgidentmod) Log() << "CHGIDENT not loaded!"; else @@ -42,7 +42,7 @@ class InspIRCdTS6Proto : public IRCDProto void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost) { - User *u = finduser(Config->s_HostServ); + User *u = finduser(Config->HostServ); if (!has_chghostmod) Log() << "CHGHOST not loaded!"; else @@ -53,7 +53,7 @@ class InspIRCdTS6Proto : public IRCDProto void SendAkillDel(const XLine *x) { - User *u = finduser(Config->s_OperServ); + User *u = finduser(Config->OperServ); send_cmd(u ? u->GetUID() : Config->Numeric, "GLINE %s", x->Mask.c_str()); } @@ -79,7 +79,7 @@ class InspIRCdTS6Proto : public IRCDProto time_t timeleft = x->Expires - Anope::CurTime; if (timeleft > 172800 || !x->Expires) timeleft = 172800; - User *u = finduser(Config->s_OperServ); + User *u = finduser(Config->OperServ); send_cmd(u ? u->GetUID() : Config->Numeric, "ADDLINE G %s@%s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast(Anope::CurTime), static_cast(timeleft), x->Reason.c_str()); } @@ -153,7 +153,7 @@ class InspIRCdTS6Proto : public IRCDProto /* SQLINE */ void SendSQLine(User *, const XLine *x) { - send_cmd(Config->Numeric, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config->s_OperServ.c_str(), static_cast(Anope::CurTime), x->Reason.c_str()); + send_cmd(Config->Numeric, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config->OperServ.c_str(), static_cast(Anope::CurTime), x->Reason.c_str()); } /* SQUIT */ @@ -183,13 +183,17 @@ class InspIRCdTS6Proto : public IRCDProto /* SVSHOLD - set */ void SendSVSHold(const Anope::string &nick) { - send_cmd(nickserv->Bot()->GetUID(), "SVSHOLD %s %u :Being held for registered user", nick.c_str(), static_cast(Config->NSReleaseTimeout)); + BotInfo *bi = findbot(Config->NickServ); + if (bi) + send_cmd(bi->GetUID(), "SVSHOLD %s %u :Being held for registered user", nick.c_str(), static_cast(Config->NSReleaseTimeout)); } /* SVSHOLD - release */ void SendSVSHoldDel(const Anope::string &nick) { - send_cmd(nickserv->Bot()->GetUID(), "SVSHOLD %s", nick.c_str()); + BotInfo *bi = findbot(Config->NickServ); + if (bi) + send_cmd(bi->GetUID(), "SVSHOLD %s", nick.c_str()); } /* UNSZLINE */ diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index 1790aaa84..961b36df3 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -14,6 +14,7 @@ #include "services.h" #include "modules.h" #include "nickserv.h" +#include "oper.h" IRCDVar myIrcd[] = { {"InspIRCd 1.1", /* ircd name */ @@ -57,11 +58,11 @@ void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost) { if (nick.empty() || vhost.empty()) return; - send_cmd(Config->s_OperServ, "CHGHOST %s %s", nick.c_str(), vhost.c_str()); + send_cmd(Config->OperServ, "CHGHOST %s %s", nick.c_str(), vhost.c_str()); } else { - BotInfo *bi = findbot(Config->s_OperServ); + BotInfo *bi = findbot(Config->OperServ); if (bi) ircdproto->SendGlobops(bi, "CHGHOST not loaded!"); } @@ -86,7 +87,7 @@ class InspIRCdProto : public IRCDProto { void SendAkillDel(const XLine *x) { - send_cmd(Config->s_OperServ, "GLINE %s", x->Mask.c_str()); + send_cmd(Config->OperServ, "GLINE %s", x->Mask.c_str()); } void SendTopic(BotInfo *whosets, Channel *c) @@ -126,7 +127,7 @@ class InspIRCdProto : public IRCDProto void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) { - send_cmd(source ? source->nick : Config->s_OperServ, "FMODE %s %u %s", dest->name.c_str(), static_cast(dest->creation_time), buf.c_str()); + send_cmd(source ? source->nick : Config->OperServ, "FMODE %s %u %s", dest->name.c_str(), static_cast(dest->creation_time), buf.c_str()); } void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) @@ -175,13 +176,13 @@ class InspIRCdProto : public IRCDProto /* UNSQLINE */ void SendSQLineDel(const XLine *x) { - send_cmd(Config->s_OperServ, "QLINE %s", x->Mask.c_str()); + send_cmd(Config->OperServ, "QLINE %s", x->Mask.c_str()); } /* SQLINE */ void SendSQLine(User *, const XLine *x) { - send_cmd(Config->ServerName, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config->s_OperServ.c_str(), static_cast(Anope::CurTime), x->Reason.c_str()); + send_cmd(Config->ServerName, "ADDLINE Q %s %s %ld 0 :%s", x->Mask.c_str(), Config->OperServ.c_str(), static_cast(Anope::CurTime), x->Reason.c_str()); } /* SQUIT */ @@ -216,7 +217,7 @@ class InspIRCdProto : public IRCDProto { if (nick.empty() || vIdent.empty()) return; - send_cmd(Config->s_OperServ, "CHGIDENT %s %s", nick.c_str(), vIdent.c_str()); + send_cmd(Config->OperServ, "CHGIDENT %s %s", nick.c_str(), vIdent.c_str()); } else Log() << "CHGIDENT not loaded!"; @@ -225,19 +226,19 @@ class InspIRCdProto : public IRCDProto /* SVSHOLD - set */ void SendSVSHold(const Anope::string &nick) { - send_cmd(Config->s_OperServ, "SVSHOLD %s %ds :Being held for registered user", nick.c_str(), static_cast(Config->NSReleaseTimeout)); + send_cmd(Config->OperServ, "SVSHOLD %s %ds :Being held for registered user", nick.c_str(), static_cast(Config->NSReleaseTimeout)); } /* SVSHOLD - release */ void SendSVSHoldDel(const Anope::string &nick) { - send_cmd(Config->s_OperServ, "SVSHOLD %s", nick.c_str()); + send_cmd(Config->OperServ, "SVSHOLD %s", nick.c_str()); } /* UNSZLINE */ void SendSZLineDel(const XLine *x) { - send_cmd(Config->s_OperServ, "ZLINE %s", x->Mask.c_str()); + send_cmd(Config->OperServ, "ZLINE %s", x->Mask.c_str()); } /* SZLINE */ @@ -326,7 +327,7 @@ class InspircdIRCdMessage : public IRCdMessage { user->Login(na->nc); if (na->nc->HasFlag(NI_UNCONFIRMED)) - user->SetMode(nickserv->Bot(), UMODE_REGISTERED); + user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } else nickserv->Validate(user); diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 9e81c2b3f..639d892bf 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -14,6 +14,7 @@ #include "services.h" #include "modules.h" #include "nickserv.h" +#include "oper.h" /* inspircd-ts6.h uses these */ static bool has_globopsmod = false; @@ -269,7 +270,7 @@ bool event_metadata(const Anope::string &source, const std::vectornick); if (nickserv && user_na && user_na->nc == nc && user_na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(nickserv->Bot(), UMODE_REGISTERED); + u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } } @@ -768,7 +769,7 @@ class ProtoInspIRCd : public Module /* InspIRCd 1.2 doesn't set -r on nick change, remove -r here. Note that if we have to set +r later * this will cancel out this -r, resulting in no mode changes. */ - u->RemoveMode(nickserv->Bot(), UMODE_REGISTERED); + u->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); } void OnServerSync(Server *s) diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 7d85bcc3f..92bbf7fba 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -14,6 +14,7 @@ #include "services.h" #include "modules.h" #include "nickserv.h" +#include "oper.h" /* inspircd-ts6.h uses these */ static bool has_chghostmod = false; @@ -280,7 +281,7 @@ bool event_metadata(const Anope::string &source, const std::vectornick); if (nickserv && user_na && user_na->nc == nc && user_na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(nickserv->Bot(), UMODE_REGISTERED); + u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } } diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index c83aa786e..438b74fac 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -12,6 +12,7 @@ #include "services.h" #include "modules.h" #include "nickserv.h" +#include "oper.h" static Anope::string TS6UPLINK; @@ -101,20 +102,20 @@ class PlexusProto : public IRCDProto void SendSGLineDel(const XLine *x) { - BotInfo *bi = findbot(Config->s_OperServ); - send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "UNXLINE * %s", x->Mask.c_str()); + BotInfo *bi = findbot(Config->OperServ); + send_cmd(bi ? bi->GetUID() : Config->OperServ, "UNXLINE * %s", x->Mask.c_str()); } void SendSGLine(User *, const XLine *x) { - BotInfo *bi = findbot(Config->s_OperServ); - send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str()); + BotInfo *bi = findbot(Config->OperServ); + send_cmd(bi ? bi->GetUID() : Config->OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str()); } void SendAkillDel(const XLine *x) { - BotInfo *bi = findbot(Config->s_OperServ); - send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "UNKLINE * %s %s", x->GetUser().c_str(), x->GetHost().c_str()); + BotInfo *bi = findbot(Config->OperServ); + send_cmd(bi ? bi->GetUID() : Config->OperServ, "UNKLINE * %s %s", x->GetUser().c_str(), x->GetHost().c_str()); } void SendSQLineDel(const XLine *x) @@ -136,8 +137,8 @@ class PlexusProto : public IRCDProto void SendAkill(User *, const XLine *x) { - BotInfo *bi = findbot(Config->s_OperServ); - send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "KLINE * %ld %s %s :%s", static_cast(x->Expires - Anope::CurTime), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str()); + BotInfo *bi = findbot(Config->OperServ); + send_cmd(bi ? bi->GetUID() : Config->OperServ, "KLINE * %ld %s %s :%s", static_cast(x->Expires - Anope::CurTime), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str()); } void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf) @@ -536,7 +537,7 @@ bool event_encap(const Anope::string &source, const std::vector & { u->Login(nc); if (user_na && user_na->nc == nc && user_na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(nickserv->Bot(), UMODE_REGISTERED); + u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } } diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 13a5e287a..95d8405d9 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -12,6 +12,7 @@ #include "services.h" #include "modules.h" #include "nickserv.h" +#include "oper.h" static Anope::string TS6UPLINK; @@ -104,20 +105,20 @@ class RatboxProto : public IRCDProto void SendSGLineDel(const XLine *x) { - BotInfo *bi = findbot(Config->s_OperServ); - send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "UNXLINE * %s", x->Mask.c_str()); + BotInfo *bi = findbot(Config->OperServ); + send_cmd(bi ? bi->GetUID() : Config->OperServ, "UNXLINE * %s", x->Mask.c_str()); } void SendSGLine(User *, const XLine *x) { - BotInfo *bi = findbot(Config->s_OperServ); - send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str()); + BotInfo *bi = findbot(Config->OperServ); + send_cmd(bi ? bi->GetUID() : Config->OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str()); } void SendAkillDel(const XLine *x) { - BotInfo *bi = findbot(Config->s_OperServ); - send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "UNKLINE * %s %s", x->GetUser().c_str(), x->GetHost().c_str()); + BotInfo *bi = findbot(Config->OperServ); + send_cmd(bi ? bi->GetUID() : Config->OperServ, "UNKLINE * %s %s", x->GetUser().c_str(), x->GetHost().c_str()); } void SendSQLineDel(const XLine *x) @@ -143,8 +144,8 @@ class RatboxProto : public IRCDProto void SendAkill(User *, const XLine *x) { - BotInfo *bi = findbot(Config->s_OperServ); - send_cmd(bi ? bi->GetUID() : Config->s_OperServ, "KLINE * %ld %s %s :%s", static_cast(x->Expires - Anope::CurTime), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str()); + BotInfo *bi = findbot(Config->OperServ); + send_cmd(bi ? bi->GetUID() : Config->OperServ, "KLINE * %ld %s %s :%s", static_cast(x->Expires - Anope::CurTime), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str()); } void SendSVSKillInternal(const BotInfo *source, const User *user, const Anope::string &buf) diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 9e7768ef3..1fb58844d 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -14,6 +14,7 @@ #include "services.h" #include "modules.h" #include "nickserv.h" +#include "oper.h" IRCDVar myIrcd[] = { {"UnrealIRCd 3.2.x", /* ircd name */ @@ -98,7 +99,7 @@ class UnrealIRCdProto : public IRCDProto void SendAkillDel(const XLine *x) { - send_cmd("", "BD - G %s %s %s", x->GetUser().c_str(), x->GetHost().c_str(), Config->s_OperServ.c_str()); + send_cmd("", "BD - G %s %s %s", x->GetUser().c_str(), x->GetHost().c_str(), Config->OperServ.c_str()); } void SendTopic(BotInfo *whosets, Channel *c) @@ -108,7 +109,7 @@ class UnrealIRCdProto : public IRCDProto void SendVhostDel(User *u) { - BotInfo *bi = findbot(Config->s_HostServ); + BotInfo *bi = findbot(Config->HostServ); u->RemoveMode(bi, UMODE_CLOAK); u->RemoveMode(bi, UMODE_VHOST); ModeManager::ProcessModes(); @@ -259,7 +260,7 @@ class UnrealIRCdProto : public IRCDProto /* UNSZLINE */ void SendSZLineDel(const XLine *x) { - send_cmd("", "BD - Z * %s %s", x->Mask.c_str(), Config->s_OperServ.c_str()); + send_cmd("", "BD - Z * %s %s", x->Mask.c_str(), Config->OperServ.c_str()); } /* SZLINE */ @@ -327,12 +328,12 @@ class UnrealIRCdProto : public IRCDProto if (!u->Account()) return; - ircdproto->SendMode(nickserv->Bot(), u, "+d %d", u->timestamp); + ircdproto->SendMode(findbot(Config->NickServ), u, "+d %d", u->timestamp); } void SendUnregisteredNick(const User *u) { - ircdproto->SendMode(nickserv->Bot(), u, "+d 1"); + ircdproto->SendMode(findbot(Config->NickServ), u, "+d 1"); } void SendChannel(Channel *c) @@ -535,7 +536,7 @@ class Unreal32IRCdMessage : public IRCdMessage { user->Login(na->nc); if (na->nc->HasFlag(NI_UNCONFIRMED) == false && nickserv) - user->SetMode(nickserv->Bot(), UMODE_REGISTERED); + user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } else if (nickserv) nickserv->Validate(user); @@ -557,7 +558,7 @@ class Unreal32IRCdMessage : public IRCdMessage { user->Login(na->nc); if (na->nc->HasFlag(NI_UNCONFIRMED) == false && nickserv) - user->SetMode(nickserv->Bot(), UMODE_REGISTERED); + user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } else if (nickserv) nickserv->Validate(user); -- cgit