diff options
author | DukePyrolator <DukePyrolator@anope.org> | 2013-07-08 05:05:13 +0200 |
---|---|---|
committer | DukePyrolator <DukePyrolator@anope.org> | 2013-07-08 05:05:13 +0200 |
commit | 2ea594d6779cb2456f91c2cbe24e5242286836b5 (patch) | |
tree | 581f532aa692aef2109e5321f8716fe78a30eb00 | |
parent | e957c7b2d27d8abb89143ee43675a72a3017226e (diff) |
added protocol support for incoming NOTICEs
-rw-r--r-- | include/messages.h | 13 | ||||
-rw-r--r-- | include/modules.h | 7 | ||||
-rw-r--r-- | modules/protocol/bahamut.cpp | 3 | ||||
-rw-r--r-- | modules/protocol/charybdis.cpp | 7 | ||||
-rw-r--r-- | modules/protocol/inspircd12.cpp | 11 | ||||
-rw-r--r-- | modules/protocol/inspircd20.cpp | 5 | ||||
-rw-r--r-- | modules/protocol/ngircd.cpp | 6 | ||||
-rw-r--r-- | modules/protocol/plexus.cpp | 6 | ||||
-rw-r--r-- | modules/protocol/ratbox.cpp | 7 | ||||
-rw-r--r-- | modules/protocol/unreal.cpp | 7 | ||||
-rw-r--r-- | src/messages.cpp | 16 |
11 files changed, 66 insertions, 22 deletions
diff --git a/include/messages.h b/include/messages.h index d226a35b7..059dd718a 100644 --- a/include/messages.h +++ b/include/messages.h @@ -9,14 +9,14 @@ * Based on the original code of Services by Andy Church. * */ - + #include "protocol.h" - + /* Common IRCD messages. * Protocol modules may chose to include some, none, or all of these handlers * as they see fit. */ - + namespace Message { @@ -94,6 +94,13 @@ namespace Message void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override; }; + struct CoreExport Notice : IRCDMessage + { + Notice(Module *creator, const Anope::string &mname = "NOTICE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override; + }; + struct CoreExport Part : IRCDMessage { Part(Module *creator, const Anope::string &mname = "PART") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } diff --git a/include/modules.h b/include/modules.h index 8948d3389..c725152eb 100644 --- a/include/modules.h +++ b/include/modules.h @@ -973,6 +973,13 @@ class CoreExport Module : public Extensible */ virtual EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) { throw NotImplementedException(); } + /** Called when we receive a NOTICE for one of our clients + * @param u The user sending the NOTICE + * @param bi The target of the NOTICE + * @param message The message + */ + virtual void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) { throw NotImplementedException(); } + /** Called when we receive a PRIVMSG for a registered channel we are in * @param u The source of the message * @param c The channel diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 4b6feae2d..162b80e0b 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -484,6 +484,7 @@ class ProtoBahamut : public Module Message::Kick message_kick; Message::Kill message_kill; Message::MOTD message_motd; + Message::Notice message_notice; Message::Part message_part; Message::Ping message_ping; Message::Privmsg message_privmsg; @@ -543,7 +544,7 @@ class ProtoBahamut : public Module ProtoBahamut(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), ircd_proto(this), message_away(this), message_capab(this), message_error(this), message_invite(this), - message_join(this), message_kick(this), message_kill(this), message_motd(this), + message_join(this), message_kick(this), message_kill(this), message_motd(this), message_notice(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), message_time(this), message_version(this), message_whois(this), diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index 7d34da8d2..0ef438b7d 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -335,6 +335,7 @@ class ProtoCharybdis : public Module Message::Kill message_kill; Message::Mode message_mode; Message::MOTD message_motd; + Message::Notice message_notice; Message::Part message_part; Message::Ping message_ping; Message::Privmsg message_privmsg; @@ -394,9 +395,9 @@ class ProtoCharybdis : public Module ProtoCharybdis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), ircd_proto(this), message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this), - message_kill(this), message_mode(this), message_motd(this), message_part(this), message_ping(this), - message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), message_time(this), - message_topic(this), message_version(this), message_whois(this), + message_kill(this), message_mode(this), message_motd(this), message_notice(this), message_part(this), + message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), + message_time(this), message_topic(this), message_version(this), message_whois(this), message_bmask("IRCDMessage", "charybdis/bmask", "ratbox/bmask"), message_join("IRCDMessage", "charybdis/join", "ratbox/join"), diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 876d387d1..228f082bc 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -1281,6 +1281,7 @@ class ProtoInspIRCd : public Module Message::Kick message_kick; Message::Kill message_kill; Message::MOTD message_motd; + Message::Notice message_notice; Message::Part message_part; Message::Ping message_ping; Message::Privmsg message_privmsg; @@ -1314,8 +1315,8 @@ class ProtoInspIRCd : public Module ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), ircd_proto(this), ssl(this, "ssl"), message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this), message_kill(this), - message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), - message_stats(this), message_topic(this), + message_motd(this), message_notice(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), + message_squit(this), message_stats(this), message_topic(this), message_chgident(this), message_setname(this, "SETNAME"), message_chgname(this, "FNAME"), message_capab(this), message_endburst(this), message_fhost(this, "FHOST"), message_sethost(this, "SETHOST"), message_fjoin(this), message_fmode(this), message_ftopic(this), @@ -1342,8 +1343,12 @@ 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. + * + * Do not set -r if we dont have a NickServ loaded - DP */ - u->RemoveMode(Config->GetClient("NickServ"), "REGISTERED"); + BotInfo *NickServ = Config->GetClient("NickServ"); + if (NickServ) + u->RemoveMode(NickServ, "REGISTERED"); } }; diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index c251b93b8..d87284038 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -674,6 +674,7 @@ class ProtoInspIRCd : public Module Message::Kick message_kick; Message::Kill message_kill; Message::MOTD message_motd; + Message::Notice message_notice; Message::Part message_part; Message::Ping message_ping; Message::Privmsg message_privmsg; @@ -704,8 +705,8 @@ class ProtoInspIRCd : public Module ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), ircd_proto(this), message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this), - message_kill(this), message_motd(this), message_part(this), message_ping(this), message_privmsg(this), - message_quit(this), message_squit(this), message_stats(this), message_topic(this), + message_kill(this), message_motd(this), message_notice(this), message_part(this), message_ping(this), + message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), message_topic(this), message_endburst("IRCDMessage", "inspircd20/endburst", "inspircd12/endburst"), message_fhost("IRCDMessage", "inspircd20/fhost", "inspircd12/fhost"), diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index a22828e3d..c1c4aac5c 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -573,6 +573,7 @@ class ProtongIRCd : public Module Message::Kick message_kick; Message::Kill message_kill; Message::MOTD message_motd; + Message::Notice message_notice; Message::Part message_part; Message::Ping message_ping; Message::Privmsg message_privmsg, message_squery; @@ -644,8 +645,9 @@ class ProtongIRCd : public Module ProtongIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), ircd_proto(this), message_capab(this), message_error(this), message_invite(this), message_kick(this), message_kill(this), - message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_squery(this, "SQUERY"), - message_quit(this), message_squit(this), message_stats(this), message_time(this), message_version(this), + message_motd(this), message_notice(this), message_part(this), message_ping(this), message_privmsg(this), + message_squery(this, "SQUERY"), message_quit(this), message_squit(this), message_stats(this), message_time(this), + message_version(this), message_005(this), message_376(this), message_chaninfo(this), message_join(this), message_metadata(this), message_mode(this), message_nick(this), message_njoin(this), message_pong(this), message_server(this), diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index cacaa59d0..9c5701d21 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -299,6 +299,7 @@ class ProtoPlexus : public Module Message::Kill message_kill; Message::Mode message_mode; Message::MOTD message_motd; + Message::Notice message_notice; Message::Part message_part; Message::Ping message_ping; Message::Privmsg message_privmsg; @@ -353,8 +354,9 @@ class ProtoPlexus : public Module ProtoPlexus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), ircd_proto(this), message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this), message_kill(this), - message_mode(this), message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), - message_squit(this), message_stats(this), message_time(this), message_topic(this), message_version(this), message_whois(this), + message_mode(this), message_motd(this), message_notice(this), message_part(this), message_ping(this), message_privmsg(this), + message_quit(this), message_squit(this), message_stats(this), message_time(this), message_topic(this), message_version(this), + message_whois(this), message_bmask("IRCDMessage", "plexus/bmask", "hybrid/bmask"), message_eob("IRCDMessage", "plexus/eob", "hybrid/eob"), message_join("IRCDMessage", "plexus/join", "hybrid/join"), message_nick("IRCDMessage", "plexus/nick", "hybrid/nick"), diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 7bae048d6..570448db2 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -192,6 +192,7 @@ class ProtoRatbox : public Module Message::Kill message_kill; Message::Mode message_mode; Message::MOTD message_motd; + Message::Notice message_notice; Message::Part message_part; Message::Ping message_ping; Message::Privmsg message_privmsg; @@ -236,9 +237,9 @@ class ProtoRatbox : public Module ProtoRatbox(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), ircd_proto(this), message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this), - message_kill(this), message_mode(this), message_motd(this), message_part(this), message_ping(this), - message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), message_time(this), - message_topic(this), message_version(this), message_whois(this), + message_kill(this), message_mode(this), message_motd(this), message_notice(this), message_part(this), + message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), + message_time(this), message_topic(this), message_version(this), message_whois(this), message_bmask("IRCDMessage", "ratbox/bmask", "hybrid/bmask"), message_join("IRCDMessage", "ratbox/join", "hybrid/join"), message_nick("IRCDMessage", "ratbox/nick", "hybrid/nick"), message_pong("IRCDMessage", "ratbox/pong", "hybrid/pong"), diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 856a4aeb4..0f4147554 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -1124,6 +1124,7 @@ class ProtoUnreal : public Module Message::Kick message_kick; Message::Kill message_kill; Message::MOTD message_motd; + Message::Notice message_notice; Message::Part message_part; Message::Ping message_ping; Message::Privmsg message_privmsg; @@ -1197,9 +1198,9 @@ class ProtoUnreal : public Module ProtoUnreal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), ircd_proto(this), message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this), - message_kill(this), message_motd(this), message_part(this), message_ping(this), message_privmsg(this), - message_quit(this), message_squit(this), message_stats(this), message_time(this), message_version(this), - message_whois(this), + message_kill(this), message_motd(this), message_notice(this), message_part(this), message_ping(this), + message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), message_time(this), + message_version(this), message_whois(this), message_capab(this), message_chghost(this), message_chgident(this), message_chgname(this), message_mode(this, "MODE"), message_svsmode(this, "SVSMODE"), message_svs2mode(this, "SVS2MODE"), message_netinfo(this), message_nick(this), message_pong(this), diff --git a/src/messages.cpp b/src/messages.cpp index 1fcc8b898..a0c5e6dfb 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -244,6 +244,22 @@ void MOTD::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) IRCD->SendNumeric(422, source.GetSource(), ":- MOTD file not found! Please contact your IRC administrator."); } +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])) + { + BotInfo *bi = BotInfo::Find(params[0]); + if (!bi) + return; + FOREACH_MOD(OnBotNotice, (u, bi, message)); + } +} + void Part::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { User *u = source.GetUser(); |