Restrict snowflake regexes to 15-20 digits
This commit is contained in:
parent
8f9819eb4c
commit
d3ac191a67
@ -177,7 +177,7 @@ class MemberConverter(IDConverter[discord.Member]):
|
|||||||
|
|
||||||
async def convert(self, ctx: Context, argument: str) -> discord.Member:
|
async def convert(self, ctx: Context, argument: str) -> discord.Member:
|
||||||
bot = ctx.bot
|
bot = ctx.bot
|
||||||
match = self._get_id_match(argument) or re.match(r'<@!?([0-9]+)>$', argument)
|
match = self._get_id_match(argument) or re.match(r'<@!?([0-9]{15,20})>$', argument)
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
result = None
|
result = None
|
||||||
user_id = None
|
user_id = None
|
||||||
@ -230,7 +230,7 @@ class UserConverter(IDConverter[discord.User]):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
async def convert(self, ctx: Context, argument: str) -> discord.User:
|
async def convert(self, ctx: Context, argument: str) -> discord.User:
|
||||||
match = self._get_id_match(argument) or re.match(r'<@!?([0-9]+)>$', argument)
|
match = self._get_id_match(argument) or re.match(r'<@!?([0-9]{15,20})>$', argument)
|
||||||
result = None
|
result = None
|
||||||
state = ctx._state
|
state = ctx._state
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ class TextChannelConverter(IDConverter[discord.TextChannel]):
|
|||||||
def _resolve_channel(ctx: Context, argument: str, iterable: Iterable[CT], type: Type[CT]) -> CT:
|
def _resolve_channel(ctx: Context, argument: str, iterable: Iterable[CT], type: Type[CT]) -> CT:
|
||||||
bot = ctx.bot
|
bot = ctx.bot
|
||||||
|
|
||||||
match = IDConverter._get_id_match(argument) or re.match(r'<#([0-9]+)>$', argument)
|
match = IDConverter._get_id_match(argument) or re.match(r'<#([0-9]{15,20})>$', argument)
|
||||||
result = None
|
result = None
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
|
|
||||||
@ -570,7 +570,7 @@ class RoleConverter(IDConverter[discord.Role]):
|
|||||||
if not guild:
|
if not guild:
|
||||||
raise NoPrivateMessage()
|
raise NoPrivateMessage()
|
||||||
|
|
||||||
match = self._get_id_match(argument) or re.match(r'<@&([0-9]+)>$', argument)
|
match = self._get_id_match(argument) or re.match(r'<@&([0-9]{15,20})>$', argument)
|
||||||
if match:
|
if match:
|
||||||
result = guild.get_role(int(match.group(1)))
|
result = guild.get_role(int(match.group(1)))
|
||||||
else:
|
else:
|
||||||
@ -649,7 +649,7 @@ class EmojiConverter(IDConverter[discord.Emoji]):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
async def convert(self, ctx: Context, argument: str) -> discord.Emoji:
|
async def convert(self, ctx: Context, argument: str) -> discord.Emoji:
|
||||||
match = self._get_id_match(argument) or re.match(r'<a?:[a-zA-Z0-9\_]+:([0-9]+)>$', argument)
|
match = self._get_id_match(argument) or re.match(r'<a?:[a-zA-Z0-9\_]{1,32}:([0-9]{15,20})>$', argument)
|
||||||
result = None
|
result = None
|
||||||
bot = ctx.bot
|
bot = ctx.bot
|
||||||
guild = ctx.guild
|
guild = ctx.guild
|
||||||
@ -687,7 +687,7 @@ class PartialEmojiConverter(Converter[discord.PartialEmoji]):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
async def convert(self, ctx: Context, argument: str) -> discord.PartialEmoji:
|
async def convert(self, ctx: Context, argument: str) -> discord.PartialEmoji:
|
||||||
match = re.match(r'<(a?):([a-zA-Z0-9\_]+):([0-9]+)>$', argument)
|
match = re.match(r'<(a?):([a-zA-Z0-9\_]{1,32}):([0-9]{15,20})>$', argument)
|
||||||
|
|
||||||
if match:
|
if match:
|
||||||
emoji_animated = bool(match.group(1))
|
emoji_animated = bool(match.group(1))
|
||||||
|
@ -763,21 +763,21 @@ class Message(Hashable):
|
|||||||
This allows you to receive the user IDs of mentioned users
|
This allows you to receive the user IDs of mentioned users
|
||||||
even in a private message context.
|
even in a private message context.
|
||||||
"""
|
"""
|
||||||
return [int(x) for x in re.findall(r'<@!?([0-9]+)>', self.content)]
|
return [int(x) for x in re.findall(r'<@!?([0-9]{15,20})>', self.content)]
|
||||||
|
|
||||||
@utils.cached_slot_property('_cs_raw_channel_mentions')
|
@utils.cached_slot_property('_cs_raw_channel_mentions')
|
||||||
def raw_channel_mentions(self):
|
def raw_channel_mentions(self):
|
||||||
"""List[:class:`int`]: A property that returns an array of channel IDs matched with
|
"""List[:class:`int`]: A property that returns an array of channel IDs matched with
|
||||||
the syntax of ``<#channel_id>`` in the message content.
|
the syntax of ``<#channel_id>`` in the message content.
|
||||||
"""
|
"""
|
||||||
return [int(x) for x in re.findall(r'<#([0-9]+)>', self.content)]
|
return [int(x) for x in re.findall(r'<#([0-9]{15,20})>', self.content)]
|
||||||
|
|
||||||
@utils.cached_slot_property('_cs_raw_role_mentions')
|
@utils.cached_slot_property('_cs_raw_role_mentions')
|
||||||
def raw_role_mentions(self):
|
def raw_role_mentions(self):
|
||||||
"""List[:class:`int`]: A property that returns an array of role IDs matched with
|
"""List[:class:`int`]: A property that returns an array of role IDs matched with
|
||||||
the syntax of ``<@&role_id>`` in the message content.
|
the syntax of ``<@&role_id>`` in the message content.
|
||||||
"""
|
"""
|
||||||
return [int(x) for x in re.findall(r'<@&([0-9]+)>', self.content)]
|
return [int(x) for x in re.findall(r'<@&([0-9]{15,20})>', self.content)]
|
||||||
|
|
||||||
@utils.cached_slot_property('_cs_channel_mentions')
|
@utils.cached_slot_property('_cs_channel_mentions')
|
||||||
def channel_mentions(self):
|
def channel_mentions(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user