]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/message.h
Add a method for getting the name of a MessageTarget.
[user/henk/code/inspircd.git] / include / message.h
index 9881fe3c923bda29a7a4d01c7b58d6374d84f931..2e3cd9bb1c88c4ef5f819d2eb8837de2cc40e090 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2017 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2017-2018 Attila Molnar <attilamolnar@hush.com>
  *
  * 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
@@ -153,4 +154,18 @@ class CoreExport MessageTarget
        {
                return static_cast<T*>(dest);
        }
+
+       /** Retrieves the name of the target of this message. */
+       const std::string& GetName() const
+       {
+               switch (type)
+               {
+                       case TYPE_CHANNEL:
+                               return Get<Channel>()->name;
+                       case TYPE_USER:
+                               return Get<User>()->nick;
+                       case TYPE_SERVER:
+                               return *Get<std::string>();
+               }
+       }
 };