Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump deps (including d.py 2.5 bump) #6529

Merged
merged 9 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/scripts/merge_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,27 @@ def iter_envs(envs: Iterable[str]) -> Iterable[Tuple[str, str]]:
python_version_marker = (
# Requirement present on less Python versions than not.
" or ".join(
f"python_version == '{python_version}'" for python_version in python_versions
f"python_version == '{python_version}'"
for python_version in sorted(python_versions)
)
if len(python_versions) < len(all_python_versions - python_versions)
# Requirement present on more Python versions than not
# This may generate an empty string when Python version is irrelevant.
else " and ".join(
f"python_version != '{python_version}'"
for python_version in all_python_versions - python_versions
for python_version in sorted(all_python_versions - python_versions)
)
)

platform_marker = (
# Requirement present on less platforms than not.
" or ".join(f"sys_platform == '{platform}'" for platform in platforms)
" or ".join(f"sys_platform == '{platform}'" for platform in sorted(platforms))
if len(platforms) < len(all_platforms - platforms)
# Requirement present on more platforms than not
# This may generate an empty string when platform is irrelevant.
else " and ".join(
f"sys_platform != '{platform}'" for platform in all_platforms - platforms
f"sys_platform != '{platform}'"
for platform in sorted(all_platforms - platforms)
)
)

Expand All @@ -169,12 +171,12 @@ def iter_envs(envs: Iterable[str]) -> Iterable[Tuple[str, str]]:
# Requirement present on less envs than not.
" or ".join(
f"(sys_platform == '{platform}' and python_version == '{python_version}')"
for platform, python_version in iter_envs(envs)
for platform, python_version in iter_envs(sorted(envs))
)
if len(envs) < len(all_envs - envs.keys())
else " and ".join(
f"(sys_platform != '{platform}' and python_version != '{python_version}')"
for platform, python_version in iter_envs(all_envs - envs.keys())
for platform, python_version in iter_envs(sorted(all_envs - envs.keys()))
)
)

Expand Down
8 changes: 8 additions & 0 deletions redbot/cogs/cleanup/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,11 +708,19 @@ async def cleanup_duplicates(self, ctx: commands.Context, number: positive_int =
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)
Expand Down
41 changes: 40 additions & 1 deletion redbot/cogs/filter/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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
Expand Down Expand Up @@ -515,6 +515,22 @@ async def check_filter(self, message: discord.Message):
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:
Expand Down Expand Up @@ -624,3 +640,26 @@ async def maybe_filter_name(self, member: discord.Member):
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())
4 changes: 4 additions & 0 deletions redbot/core/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@
RangeError as RangeError,
parameter as parameter,
HybridCommandError as HybridCommandError,
SoundboardSoundConverter as SoundboardSoundConverter,
SoundboardSoundNotFound as SoundboardSoundNotFound,
)

__all__ = (
Expand Down Expand Up @@ -397,4 +399,6 @@
"RangeError",
"parameter",
"HybridCommandError",
"SoundboardSoundConverter",
"SoundboardSoundNotFound",
)
3 changes: 2 additions & 1 deletion redbot/core/utils/tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ async def files_from_attach(

"""
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:
Expand Down
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ rich
schema
typing_extensions
yarl
zstandard
distro; sys_platform == "linux"
uvloop; sys_platform != "win32" and platform_python_implementation == "CPython"
10 changes: 6 additions & 4 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ brotli==1.1.0
# via -r base.in
click==8.1.8
# via -r base.in
discord-py==2.4.0
discord-py==2.5.1
# via
# -r base.in
# red-lavalink
Expand Down Expand Up @@ -46,7 +46,7 @@ platformdirs==4.3.6
# via -r base.in
propcache==0.2.0
# via yarl
psutil==6.1.1
psutil==7.0.0
# via -r base.in
pygments==2.19.1
# via rich
Expand Down Expand Up @@ -77,17 +77,19 @@ yarl==1.15.2
# via
# -r base.in
# aiohttp
zstandard==0.23.0
# via -r base.in
async-timeout==4.0.3; python_version != "3.11"
# via aiohttp
colorama==0.4.6; sys_platform == "win32"
# via click
distro==1.9.0; sys_platform == "linux" and sys_platform == "linux"
# via -r base.in
importlib-metadata==8.5.0; python_version != "3.11" and python_version != "3.10"
importlib-metadata==8.5.0; python_version != "3.10" and python_version != "3.11"
# via markdown
pytz==2025.1; python_version == "3.8"
# via babel
uvloop==0.21.0; (sys_platform != "win32" and platform_python_implementation == "CPython") and sys_platform != "win32"
# via -r base.in
zipp==3.20.2; python_version != "3.11" and python_version != "3.10"
zipp==3.20.2; python_version != "3.10" and python_version != "3.11"
# via importlib-metadata
Loading