X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmessage.h;h=3a7c7018e7a772d97c5099a3f0f1c7bacda015bb;hb=327bacd3687f307a5f8586856a94b16c9e4370bf;hp=1799e61192c9cde5260e5e6d9547fc2130663d16;hpb=58a0a7e01422e62de1565a8eb0a1febdc463d04d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/message.h b/include/message.h index 1799e6119..3a7c7018e 100644 --- a/include/message.h +++ b/include/message.h @@ -1,7 +1,8 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2017 Peter Powell + * Copyright (C) 2017-2018, 2020 Sadie Powell + * Copyright (C) 2017-2018 Attila Molnar * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -32,14 +33,17 @@ enum MessageType class CoreExport MessageDetails { public: + /** Whether to echo the message at all. */ + bool echo; + /* Whether to send the original message back to clients with echo-message support. */ - bool echooriginal; + bool echo_original; /** The users who are exempted from receiving this message. */ CUList exemptions; /* The original message as sent by the user. */ - const std::string originaltext; + const std::string original_text; /** IRCv3 message tags sent to the server by the user. */ const ClientProtocol::TagMap tags_in; @@ -53,9 +57,28 @@ class CoreExport MessageDetails /** The type of message. */ const MessageType type; + /** Determines whether the specified message is a CTCP. If the specified message + * is a CTCP then the CTCP name and CTCP body are extracted and stored in the + * name and body references. + * @param name The location to store the parsed CTCP name. + * @param body The location to store the parsed CTCP body. + */ + virtual bool IsCTCP(std::string& name, std::string& body) const = 0; + + /** Determines whether the specified message is a CTCP. If the specified message + * is a CTCP then the CTCP name is extracted and stored in the name reference. + * @param name The location to store the parsed CTCP name. + */ + virtual bool IsCTCP(std::string& name) const = 0; + + /** Determines whether the specified message is a CTCP. */ + virtual bool IsCTCP() const = 0; + + protected: MessageDetails(MessageType mt, const std::string& msg, const ClientProtocol::TagMap& tags) - : echooriginal(false) - , originaltext(msg) + : echo(true) + , echo_original(false) + , original_text(msg) , tags_in(tags) , text(msg) , type(mt) @@ -131,4 +154,23 @@ class CoreExport MessageTarget { return static_cast(dest); } + + /** Retrieves the name of the target of this message. */ + const std::string& GetName() const + { + switch (type) + { + case TYPE_CHANNEL: + return Get()->name; + case TYPE_USER: + return Get()->nick; + case TYPE_SERVER: + return *Get(); + } + + // We should never reach this point during a normal execution but + // handle it just in case. + static const std::string target = "*"; + return target; + } };