summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2020-01-23 17:16:17 +0000
committerSadie Powell <sadie@witchery.services>2020-01-23 17:22:25 +0000
commita697104a8c768228ce494967c11ff669d4aa3555 (patch)
tree03069ff0ec2a9f96d489b3b973ea1983f65fb1ce /include
parentb7382a91384e6e9463ba85c6effec32f071dd4ca (diff)
Add a method for getting the name of a MessageTarget.
This fixes a minor bug in the filter module where the target would be blank in messages when a server-targetted message matches a filter.
Diffstat (limited to 'include')
-rw-r--r--include/message.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/message.h b/include/message.h
index 39ddfaa40..2e3cd9bb1 100644
--- a/include/message.h
+++ b/include/message.h
@@ -154,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>();
+ }
+ }
};