mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-05 17:02:32 -05:00
Bump deps (including d.py 2.5 bump) (#6529)
Co-authored-by: Kowlin <10947836+Kowlin@users.noreply.github.com>
This commit is contained in:
@@ -708,11 +708,19 @@ class Cleanup(commands.Cog):
|
||||
def check(m):
|
||||
if m.attachments:
|
||||
return False
|
||||
if m.components:
|
||||
return False
|
||||
if m.poll:
|
||||
return False
|
||||
if m.activity:
|
||||
return False
|
||||
ref = m.reference
|
||||
c = (
|
||||
m.author.id,
|
||||
m.content,
|
||||
[embed.to_dict() for embed in m.embeds],
|
||||
[sticker.id for sticker in m.stickers],
|
||||
ref and (ref.type, ref.message_id, ref.channel_id),
|
||||
)
|
||||
if c in msgs:
|
||||
spam.append(m)
|
||||
|
||||
@@ -2,7 +2,7 @@ import asyncio
|
||||
import discord
|
||||
import re
|
||||
from datetime import timezone
|
||||
from typing import Union, Set, Literal, Optional
|
||||
from typing import Union, Set, Literal, Optional, Iterable, Dict, Any
|
||||
|
||||
from redbot.core import Config, modlog, commands
|
||||
from redbot.core.bot import Red
|
||||
@@ -515,6 +515,22 @@ class Filter(commands.Cog):
|
||||
texts.append(answer.text or "")
|
||||
for attachment in message.attachments:
|
||||
texts.append(attachment.description or "")
|
||||
|
||||
if (
|
||||
message.reference is not None
|
||||
and message.reference.type is discord.MessageReferenceType.forward
|
||||
):
|
||||
# unlike user messages, forwards can include things that bots can send
|
||||
# since you can forward a bot's message
|
||||
for snapshot in message.message_snapshots:
|
||||
texts.append(snapshot.content)
|
||||
for attachment in snapshot.attachments:
|
||||
texts.append(attachment.description or "")
|
||||
for embed in snapshot.embeds:
|
||||
texts.extend(_extract_string_values(embed.to_dict().values()))
|
||||
for component in snapshot.components:
|
||||
texts.extend(_extract_string_values_from_component(component))
|
||||
|
||||
hits = await self.filter_hits(message.channel, *texts)
|
||||
|
||||
if hits:
|
||||
@@ -624,3 +640,26 @@ class Filter(commands.Cog):
|
||||
except discord.HTTPException:
|
||||
pass
|
||||
return
|
||||
|
||||
|
||||
def _extract_string_values_from_component(
|
||||
component: Union[discord.ActionRow, discord.Button, discord.SelectMenu],
|
||||
) -> Iterable[str]:
|
||||
if isinstance(component, discord.ActionRow):
|
||||
for child in component.children:
|
||||
yield from _extract_string_values_from_component(child)
|
||||
elif isinstance(component, discord.Button):
|
||||
yield component.url
|
||||
yield component.label
|
||||
elif isinstance(component, discord.SelectMenu):
|
||||
yield component.placeholder
|
||||
|
||||
|
||||
def _extract_string_values(data: Iterable[Any]) -> Iterable[str]:
|
||||
for value in data:
|
||||
if isinstance(value, str):
|
||||
yield value
|
||||
elif isinstance(value, list):
|
||||
yield from _extract_string_values(value)
|
||||
elif isinstance(value, dict):
|
||||
yield from _extract_string_values(value.values())
|
||||
|
||||
@@ -206,6 +206,8 @@ from discord.ext.commands import (
|
||||
RangeError as RangeError,
|
||||
parameter as parameter,
|
||||
HybridCommandError as HybridCommandError,
|
||||
SoundboardSoundConverter as SoundboardSoundConverter,
|
||||
SoundboardSoundNotFound as SoundboardSoundNotFound,
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
@@ -397,4 +399,6 @@ __all__ = (
|
||||
"RangeError",
|
||||
"parameter",
|
||||
"HybridCommandError",
|
||||
"SoundboardSoundConverter",
|
||||
"SoundboardSoundNotFound",
|
||||
)
|
||||
|
||||
@@ -162,7 +162,8 @@ class Tunnel(metaclass=TunnelMeta):
|
||||
|
||||
"""
|
||||
files = []
|
||||
max_size = 26214400
|
||||
# DEP-WARN
|
||||
max_size = discord.utils.DEFAULT_FILE_SIZE_LIMIT_BYTES
|
||||
if m.attachments and sum(a.size for a in m.attachments) <= max_size:
|
||||
for a in m.attachments:
|
||||
if images_only and a.height is None:
|
||||
|
||||
Reference in New Issue
Block a user