Add get_raw_[channel_]mentions to Message

This commit is contained in:
Rapptz 2015-11-19 23:01:43 -05:00
parent e88c194e9a
commit da37ff16c1

View File

@ -28,6 +28,7 @@ from . import utils
from .user import User
from .member import Member
from .object import Object
import re
class Message(object):
"""Represents a message from Discord.
@ -109,6 +110,24 @@ class Message(object):
if member is not None:
self.mentions.append(member)
def get_raw_mentions(self):
"""Returns an array of user IDs matched with the syntax of
<@user_id> in the message content.
This allows you receive the user IDs of mentioned users
even in a private message context.
"""
return re.findall(r'<@(\d+)>', self.content)
def get_raw_channel_mentions(self):
"""Returns an array of channel IDs matched with the syntax of
<#channel_id> in the message content.
This allows you receive the channel IDs of mentioned users
even in a private message context.
"""
return re.findall(r'<#(\d+)>', self.content)
def _handle_upgrades_and_server(self, channel_id):
self.server = None
if self.channel is None: