Skip to content

Commit

Permalink
Merge branch 'V3' into V3_dpy2
Browse files Browse the repository at this point in the history
Signed-off-by: Fixator10 <[email protected]>
  • Loading branch information
fixator10 authored Apr 18, 2024
2 parents 18c4632 + 5f2ccb4 commit bb1817f
Show file tree
Hide file tree
Showing 21 changed files with 170 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
auto-approve:
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v3
- uses: hmarr/auto-approve-action@v4
if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'pre-commit-ci[bot]' || github.actor == 'github-actions[bot]' }}
with:
github-token: "${{ secrets.REVIEW_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- run: "python -m pip install black"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
setup-python-dependencies: false
languages: ${{ matrix.language }}
Expand All @@ -45,7 +45,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -59,4 +59,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v4

- name: Update translations
uses: crowdin/github-action@v1.13.1
uses: crowdin/github-action@v1.20.2
with:
download_translations: true
commit_message: '[automated] update translations from Crowdin'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
uses: actions/dependency-review-action@v4
with:
# Possible values: "critical", "high", "moderate", "low"
# fail-on-severity: critical
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/isort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- run: "python -m pip install isort"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
pr-labeler:
runs-on: ubuntu-latest
steps:
- uses: TimonVS/pr-labeler-action@v4
- uses: TimonVS/pr-labeler-action@v5
with:
configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
env:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ default_language_version:
python: python3.11
repos:
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.4.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
ci:
Expand Down
24 changes: 15 additions & 9 deletions adminutils/adminutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ async def emoji_add(self, ctx, name: str, url: str, *roles: discord.Role):
roles=roles,
reason=get_audit_reason(
ctx.author,
_("Restricted to roles: {}").format(", ".join(role.name for role in roles))
if roles
else None,
(
_("Restricted to roles: {}").format(", ".join(role.name for role in roles))
if roles
else None
),
),
)
except discord.HTTPException as e:
Expand Down Expand Up @@ -259,9 +261,11 @@ async def emote_steal(
roles=roles,
reason=get_audit_reason(
ctx.author,
_("Restricted to roles: {}").format(", ".join(role.name for role in roles))
if roles
else None,
(
_("Restricted to roles: {}").format(", ".join(role.name for role in roles))
if roles
else None
),
),
)
await ctx.tick()
Expand Down Expand Up @@ -290,9 +294,11 @@ async def emoji_rename(
roles=roles,
reason=get_audit_reason(
ctx.author,
_("Restricted to roles: ").format(", ".join(role.name for role in roles))
if roles
else None,
(
_("Restricted to roles: ").format(", ".join(role.name for role in roles))
if roles
else None
),
),
)
except discord.Forbidden:
Expand Down
18 changes: 9 additions & 9 deletions captcha/commands/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,14 @@ async def add_roles(self, ctx: commands.Context, *roles: discord.Role):
for role in roles:
async with self.data.guild(ctx.guild).autoroles() as roles_list:
if role.position >= ctx.me.top_role.position:
error[
role.name
] = "This role is higher than my highest role in the role hierarchy."
error[role.name] = (
"This role is higher than my highest role in the role hierarchy."
)
continue
if role.position >= ctx.author.top_role.position:
error[
role.name
] = "This role is higher than your own in the discord hierarchy."
error[role.name] = (
"This role is higher than your own in the discord hierarchy."
)
continue
if role.id not in roles_list:
roles_list.append(role.id)
Expand Down Expand Up @@ -356,9 +356,9 @@ async def remove_roles(self, ctx: commands.Context, *roles: discord.Role):
async with self.data.guild(ctx.guild).autoroles() as roles_list:
for role in roles:
if role.position >= ctx.author.top_role.position:
error[
role.name
] = "This role is higher than your own in the discord hierarchy."
error[role.name] = (
"This role is higher than your own in the discord hierarchy."
)
continue
if role.id in roles_list:
roles_list.remove(role.id)
Expand Down
96 changes: 62 additions & 34 deletions datautils/datautils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ async def fetchwidget(self, ctx, *, server_id: int):
em.add_field(
name=_("Features"),
value="\n".join(_(GUILD_FEATURES.get(f, f)) for f in guild.features).format(
banner=guild.banner and f" [🔗]({guild.banner_url_as(format='png')})" or "",
splash=guild.splash and f" [🔗]({guild.splash_url_as(format='png')})" or "",
banner=guild.banner
and f" [🔗]({guild.banner_url_as(format='png')})"
or "",
splash=guild.splash
and f" [🔗]({guild.splash_url_as(format='png')})"
or "",
discovery=getattr(guild, "discovery_splash", None)
and f" [🔗]({guild.discovery_splash_url_as(format='png')})"
or "",
Expand Down Expand Up @@ -263,35 +267,55 @@ async def sinfo(self, ctx, *, server: commands.GuildConverter = None):
)
em.add_field(
name=_("Verification level"),
value=_("None")
if server.verification_level == discord.VerificationLevel.none
else _("Low")
if server.verification_level == discord.VerificationLevel.low
else _("Medium")
if server.verification_level == discord.VerificationLevel.medium
else _("High")
if server.verification_level == discord.VerificationLevel.high
else _("Highest")
if server.verification_level == discord.VerificationLevel.extreme
else _("Unknown"),
value=(
_("None")
if server.verification_level == discord.VerificationLevel.none
else (
_("Low")
if server.verification_level == discord.VerificationLevel.low
else (
_("Medium")
if server.verification_level == discord.VerificationLevel.medium
else (
_("High")
if server.verification_level == discord.VerificationLevel.high
else (
_("Highest")
if server.verification_level == discord.VerificationLevel.extreme
else _("Unknown")
)
)
)
)
),
)
em.add_field(
name=_("Explicit content filter"),
value=_("Don't scan any messages.")
if server.explicit_content_filter == discord.ContentFilter.disabled
else _("Scan messages from members without a role.")
if server.explicit_content_filter == discord.ContentFilter.no_role
else _("Scan messages sent by all members.")
if server.explicit_content_filter == discord.ContentFilter.all_members
else _("Unknown"),
value=(
_("Don't scan any messages.")
if server.explicit_content_filter == discord.ContentFilter.disabled
else (
_("Scan messages from members without a role.")
if server.explicit_content_filter == discord.ContentFilter.no_role
else (
_("Scan messages sent by all members.")
if server.explicit_content_filter == discord.ContentFilter.all_members
else _("Unknown")
)
)
),
)
em.add_field(
name=_("Default notifications"),
value=_("All messages")
if server.default_notifications == discord.NotificationLevel.all_messages
else _("Only @mentions")
if server.default_notifications == discord.NotificationLevel.only_mentions
else _("Unknown"),
value=(
_("All messages")
if server.default_notifications == discord.NotificationLevel.all_messages
else (
_("Only @mentions")
if server.default_notifications == discord.NotificationLevel.only_mentions
else _("Unknown")
)
),
)
em.add_field(name=_("2FA admins"), value=bool_emojify(server.mfa_level))
if server.rules_channel:
Expand Down Expand Up @@ -432,15 +456,19 @@ async def cinfo(
changed_roles = sorted(channel.changed_roles, key=lambda r: r.position, reverse=True)
em = discord.Embed(
title=chat.escape(str(channel.name), formatting=True),
description=topic
if (topic := getattr(channel, "topic", None))
else "\N{SPEECH BALLOON}: {} | \N{SPEAKER}: {} | \N{SATELLITE ANTENNA}: {}".format(
len(channel.text_channels),
len(channel.voice_channels),
len(channel.stage_channels),
)
if isinstance(channel, discord.CategoryChannel)
else discord.Embed.Empty,
description=(
topic
if (topic := getattr(channel, "topic", None))
else (
"\N{SPEECH BALLOON}: {} | \N{SPEAKER}: {} | \N{SATELLITE ANTENNA}: {}".format(
len(channel.text_channels),
len(channel.voice_channels),
len(channel.stage_channels),
)
if isinstance(channel, discord.CategoryChannel)
else discord.Embed.Empty
)
),
color=await ctx.embed_color(),
)
em.add_field(name=_("ID"), value=channel.id)
Expand Down
6 changes: 3 additions & 3 deletions datautils/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def __init__(self, entries):
async def format_page(self, menu: ChannelsMenu, entries):
e = discord.Embed(
title="{}:".format(_(KNOWN_CHANNEL_TYPES[menu.channel_type][1])),
description=chat.box("\n".join(c.name for c in entries))
if entries
else _("No channels"),
description=(
chat.box("\n".join(c.name for c in entries)) if entries else _("No channels")
),
)
e.set_footer(
text=_("Page {}/{} • {}: {} • Total channels: {}").format(
Expand Down
16 changes: 10 additions & 6 deletions godvilledata/godvilledata.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ async def godville(self, ctx, *, god: GodConverter):
text_header = "{} и его {}\n{}\n".format(
chat.bold(profile.god),
chat.bold(profile.name),
chat.italics(chat.escape(profile.motto.strip(), formatting=True))
if profile.motto
else chat.inline("Здесь ничего нет"),
(
chat.italics(chat.escape(profile.motto.strip(), formatting=True))
if profile.motto
else chat.inline("Здесь ничего нет")
),
)
if profile.arena_is_in_fight:
text_header += "В сражении: {}\n".format(profile.fight_type_rus)
Expand Down Expand Up @@ -207,9 +209,11 @@ async def godvillegame(self, ctx, *, godname: str):
text_header = "{} and his {}\n{}\n".format(
chat.bold(profile.god),
chat.bold(profile.name),
chat.italics(chat.escape(profile.motto.strip(), formatting=True))
if profile.motto
else chat.inline("Nothing here"),
(
chat.italics(chat.escape(profile.motto.strip(), formatting=True))
if profile.motto
else chat.inline("Nothing here")
),
)
if profile.arena_is_in_fight:
text_header += "In fight: {}\n".format(profile.fight_type_rus)
Expand Down
6 changes: 3 additions & 3 deletions leveler/commands/lvladmin/badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ async def addbadge(
badge_name = "{}_{}".format(name, serverid)
if badge_name in userbadges.keys():
user_priority_num = userbadges[badge_name]["priority_num"]
new_badge[
"priority_num"
] = user_priority_num # maintain old priority number set by user
new_badge["priority_num"] = (
user_priority_num # maintain old priority number set by user
)
userbadges[badge_name] = new_badge
await self.db.users.update_one(
{"user_id": user["user_id"]},
Expand Down
8 changes: 5 additions & 3 deletions leveler/commands/lvladmin/debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ async def debug_info(self, ctx):
("DB lock locked", self._db_lock.locked()),
(
"DB lock queue",
"N/A"
if self._db_lock._waiters is None
else len(self._db_lock._waiters),
(
"N/A"
if self._db_lock._waiters is None
else len(self._db_lock._waiters)
),
),
("pymongo version", pymongoversion),
("motor version", motorversion),
Expand Down
6 changes: 3 additions & 3 deletions leveler/commands/lvlset/badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ async def buy_badge(self, ctx, is_global: Optional[bool], *, name: str):
return
if badge_info["price"] <= await bank.get_balance(user):
await bank.withdraw_credits(user, badge_info["price"])
userinfo["badges"][
"{}_{}".format(name, str(serverid))
] = server_badges[name]
userinfo["badges"]["{}_{}".format(name, str(serverid))] = (
server_badges[name]
)
await self.db.users.update_one(
{"user_id": userinfo["user_id"]},
{"$set": {"badges": userinfo["badges"]}},
Expand Down
Loading

0 comments on commit bb1817f

Please sign in to comment.