X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmessage.h;h=3a7c7018e7a772d97c5099a3f0f1c7bacda015bb;hb=327bacd3687f307a5f8586856a94b16c9e4370bf;hp=39ddfaa406e6f36aab59a44fe1194c0bd4a39228;hpb=aa692dc1039b63deef7886e914ec499abe7facaf;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/message.h b/include/message.h index 39ddfaa40..3a7c7018e 100644 --- a/include/message.h +++ b/include/message.h @@ -1,7 +1,7 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2017-2018 Sadie 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 @@ -154,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; + } };