Add Message.channel_mentions
This commit is contained in:
parent
da37ff16c1
commit
acbbaa39ad
@ -72,6 +72,10 @@ class Message(object):
|
|||||||
|
|
||||||
A list of :class:`Member` that were mentioned. If the message is in a private message
|
A list of :class:`Member` that were mentioned. If the message is in a private message
|
||||||
then the list is always empty.
|
then the list is always empty.
|
||||||
|
.. attribute:: channel_mentions
|
||||||
|
|
||||||
|
A list of :class:`Channel` that were mentioned. If the message is in a private message
|
||||||
|
then the list is always empty.
|
||||||
.. attribute:: id
|
.. attribute:: id
|
||||||
|
|
||||||
The message ID.
|
The message ID.
|
||||||
@ -100,6 +104,7 @@ class Message(object):
|
|||||||
|
|
||||||
def _handle_mentions(self, mentions):
|
def _handle_mentions(self, mentions):
|
||||||
self.mentions = []
|
self.mentions = []
|
||||||
|
self.channel_mentions = []
|
||||||
if getattr(self.channel, 'is_private', True):
|
if getattr(self.channel, 'is_private', True):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -110,6 +115,13 @@ class Message(object):
|
|||||||
if member is not None:
|
if member is not None:
|
||||||
self.mentions.append(member)
|
self.mentions.append(member)
|
||||||
|
|
||||||
|
if self.server is not None:
|
||||||
|
channel_mentions = self.get_raw_channel_mentions()
|
||||||
|
for mention in channel_mentions:
|
||||||
|
channel = utils.find(lambda m: m.id == mention, self.server.channels)
|
||||||
|
if channel is not None:
|
||||||
|
self.channel_mentions.append(channel)
|
||||||
|
|
||||||
def get_raw_mentions(self):
|
def get_raw_mentions(self):
|
||||||
"""Returns an array of user IDs matched with the syntax of
|
"""Returns an array of user IDs matched with the syntax of
|
||||||
<@user_id> in the message content.
|
<@user_id> in the message content.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user