]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/message.h
Lower <sts:duration> to 5m to prevent misconfigs denying access.
[user/henk/code/inspircd.git] / include / message.h
index 39ddfaa406e6f36aab59a44fe1194c0bd4a39228..3a7c7018e7a772d97c5099a3f0f1c7bacda015bb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2017-2018, 2020 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
@@ -154,4 +154,23 @@ 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>();
+               }
+
+               // We should never reach this point during a normal execution but
+               // handle it just in case.
+               static const std::string target = "*";
+               return target;
+       }
 };