[commands] Update MessageConverter link regex
Remove redundant parts of the MessageConverter regexes and support www
This commit is contained in:
parent
873ed87caa
commit
c54d6f03c5
@ -254,12 +254,11 @@ class MessageConverter(Converter):
|
|||||||
.. versionchanged:: 1.5
|
.. versionchanged:: 1.5
|
||||||
Raise :exc:`.ChannelNotFound`, `MessageNotFound` or `ChannelNotReadable` instead of generic :exc:`.BadArgument`
|
Raise :exc:`.ChannelNotFound`, `MessageNotFound` or `ChannelNotReadable` instead of generic :exc:`.BadArgument`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
async def convert(self, ctx, argument):
|
async def convert(self, ctx, argument):
|
||||||
id_regex = re.compile(r'^(?:(?P<channel_id>[0-9]{15,21})-)?(?P<message_id>[0-9]{15,21})$')
|
id_regex = re.compile(r'(?:(?P<channel_id>[0-9]{15,21})-)?(?P<message_id>[0-9]{15,21})$')
|
||||||
link_regex = re.compile(
|
link_regex = re.compile(
|
||||||
r'^https?://(?:(ptb|canary)\.)?discord(?:app)?\.com/channels/'
|
r'https?://(?:(ptb|canary|www)\.)?discord(?:app)?\.com/channels/'
|
||||||
r'(?:([0-9]{15,21})|(@me))'
|
r'(?:[0-9]{15,21}|@me)'
|
||||||
r'/(?P<channel_id>[0-9]{15,21})/(?P<message_id>[0-9]{15,21})/?$'
|
r'/(?P<channel_id>[0-9]{15,21})/(?P<message_id>[0-9]{15,21})/?$'
|
||||||
)
|
)
|
||||||
match = id_regex.match(argument) or link_regex.match(argument)
|
match = id_regex.match(argument) or link_regex.match(argument)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user