diff options
| author | Rapptz <[email protected]> | 2015-11-19 23:01:43 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-11-19 23:01:43 -0500 |
| commit | da37ff16c190d430af823f7c483f09f9bb819ca2 (patch) | |
| tree | 8f36a851e285208c039fa006855096708a076194 | |
| parent | Fix is_private check in mentions array handling. (diff) | |
| download | discord.py-da37ff16c190d430af823f7c483f09f9bb819ca2.tar.xz discord.py-da37ff16c190d430af823f7c483f09f9bb819ca2.zip | |
Add get_raw_[channel_]mentions to Message
| -rw-r--r-- | discord/message.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/discord/message.py b/discord/message.py index 209c1419..b70af032 100644 --- a/discord/message.py +++ b/discord/message.py @@ -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: |