Skip to content

Commit 9806725

Browse files
Merge branch 'main' into feat/reminder-add-notify
2 parents 8efc22d + 28ea3bc commit 9806725

84 files changed

Lines changed: 4027 additions & 2430 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
**/bot/exts/moderation/*silence.py @MarkKoz
44
bot/exts/info/codeblock/** @MarkKoz
55
bot/exts/utils/extensions.py @MarkKoz
6-
bot/exts/utils/snekbox.py @MarkKoz @jb3
7-
bot/exts/moderation/** @mbaruh @Den4200 @ks129 @jb3
8-
bot/exts/info/** @Den4200 @jb3
9-
bot/exts/info/information.py @mbaruh @jb3
6+
bot/exts/utils/snekbox.py @MarkKoz
7+
bot/exts/moderation/** @mbaruh
8+
bot/exts/info/information.py @mbaruh
109
bot/exts/filtering/** @mbaruh
11-
bot/exts/fun/** @ks129
12-
bot/exts/utils/** @ks129 @jb3
1310
bot/exts/recruitment/** @wookie184
1411

1512
# Utils
@@ -21,10 +18,6 @@ tests/_autospec.py @MarkKoz
2118
tests/bot/exts/test_cogs.py @MarkKoz
2219

2320
# CI & Docker
24-
.github/workflows/** @MarkKoz @SebastiaanZ @Den4200 @jb3
25-
Dockerfile @MarkKoz @Den4200 @jb3
26-
docker-compose.yml @MarkKoz @Den4200 @jb3
27-
28-
# Statistics
29-
bot/async_stats.py @jb3
30-
bot/exts/info/stats.py @jb3
21+
.github/workflows/** @MarkKoz
22+
Dockerfile @MarkKoz
23+
docker-compose.yml @MarkKoz

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "daily"
7+
ignore:
8+
update-types:
9+
- sem-ver:patch
10+
- sem-ver:minor
711
- package-ecosystem: "github-actions"
812
directory: "/"
913
schedule:

.github/workflows/build-deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
# and with the short SHA of the commit.
4141

4242
- name: Build and push
43-
uses: docker/build-push-action@v5
43+
uses: docker/build-push-action@v6
4444
with:
4545
context: .
4646
file: ./Dockerfile
@@ -77,6 +77,7 @@ jobs:
7777
- name: Deploy to Kubernetes
7878
uses: azure/k8s-deploy@v5
7979
with:
80+
namespace: bots
8081
manifests: |
81-
infra/kubernetes/namespaces/default/bot/deployment.yaml
82+
infra/kubernetes/namespaces/bots/bot/deployment.yaml
8283
images: 'ghcr.io/python-discord/bot:${{ inputs.sha-tag }}'

.github/workflows/lint-test.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,25 @@ jobs:
3232
uses: actions/checkout@v4
3333

3434
- name: Install Python Dependencies
35-
uses: HassanAbouelela/actions/setup-python@setup-python_v1.4.2
35+
uses: HassanAbouelela/actions/setup-python@setup-python_v1.6.0
3636
with:
37-
python_version: '3.11'
37+
python_version: '3.12'
3838

3939
# Check all of our non-dev dependencies are compatible with the MIT license.
4040
# If you added a new dependencies that is being rejected,
4141
# please make sure it is compatible with the license for this project,
4242
# and add it to the ALLOWED_LICENSE variable
43+
44+
# NOTE: at time of writing pip-licenses is not PEP-639 compliant
45+
# so is not detecting the license for packages now following that style.
46+
# As a temp fix, add packages to the ignore list after manually checking
47+
# that the license in use is compatible with ours.
48+
# Ref: https://github.com/raimon49/pip-licenses/issues/225
4349
- name: Check Dependencies License
4450
run: |
51+
poetry self add poetry-plugin-export
4552
pip-licenses --allow-only="$ALLOWED_LICENSE" \
53+
--ignore-packages attrs \
4654
--package $(poetry export -f requirements.txt --without-hashes | sed "s/==.*//g" | tr "\n" " ")
4755
4856
- name: Run pre-commit hooks
@@ -53,7 +61,10 @@ jobs:
5361
run: "ruff check --output-format=github ."
5462

5563
- name: Run tests and generate coverage report
56-
run: pytest -n auto --cov --disable-warnings -q
64+
run: pytest -n auto --cov -q
65+
env:
66+
# Use "sys.monitoring" based coverage backend for better speed (see #3075)
67+
COVERAGE_CORE: sysmon
5768

5869
# Prepare the Pull Request Payload artifact. If this fails, we
5970
# we fail silently using the `continue-on-error` option. It's

.github/workflows/sentry_release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ jobs:
1212
uses: actions/checkout@v4
1313

1414
- name: Create a Sentry.io release
15-
uses: tclindner/sentry-releases-action@v1.2.0
15+
uses: getsentry/action-release@v1
1616
env:
1717
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
1818
SENTRY_ORG: python-discord
1919
SENTRY_PROJECT: bot
2020
with:
21-
tagName: ${{ github.sha }}
2221
environment: production
23-
releaseNamePrefix: bot@
22+
version_prefix: bot@

.github/workflows/status_embed.yaml

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,6 @@ concurrency:
1313

1414
jobs:
1515
status_embed:
16-
# We need to send a status embed whenever the workflow
17-
# sequence we're running terminates. There are a number
18-
# of situations in which that happens:
19-
#
20-
# 1. We reach the end of the Deploy workflow, without
21-
# it being skipped.
22-
#
23-
# 2. A `pull_request` triggered a Lint & Test workflow,
24-
# as the sequence always terminates with one run.
25-
#
26-
# 3. If any workflow ends in failure or was cancelled.
27-
if: >-
28-
(github.event.workflow_run.name == 'Deploy' && github.event.workflow_run.conclusion != 'skipped') ||
29-
github.event.workflow_run.event == 'pull_request' ||
30-
github.event.workflow_run.conclusion == 'failure' ||
31-
github.event.workflow_run.conclusion == 'cancelled'
3216
name: Send Status Embed to Discord
3317
runs-on: ubuntu-latest
3418

@@ -46,10 +30,10 @@ jobs:
4630
curl -sSL -H "Authorization: token $GITHUB_TOKEN" -o pull_request_payload.zip $DOWNLOAD_URL || exit 2
4731
unzip -p pull_request_payload.zip > pull_request_payload.json
4832
[ -s pull_request_payload.json ] || exit 3
49-
echo "::set-output name=pr_author_login::$(jq -r '.user.login // empty' pull_request_payload.json)"
50-
echo "::set-output name=pr_number::$(jq -r '.number // empty' pull_request_payload.json)"
51-
echo "::set-output name=pr_title::$(jq -r '.title // empty' pull_request_payload.json)"
52-
echo "::set-output name=pr_source::$(jq -r '.head.label // empty' pull_request_payload.json)"
33+
echo "pr_author_login=$(jq -r '.user.login // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
34+
echo "pr_number=$(jq -r '.number // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
35+
echo "pr_title=$(jq -r '.title // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
36+
echo "pr_source=$(jq -r '.head.label // empty' pull_request_payload.json)" >> $GITHUB_OUTPUT
5337
env:
5438
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5539

@@ -64,14 +48,12 @@ jobs:
6448
webhook_id: '784184528997842985'
6549
webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }}
6650

67-
# Workflow information
51+
# We need to provide the information of the workflow that
52+
# triggered this workflow instead of this workflow.
6853
workflow_name: ${{ github.event.workflow_run.name }}
6954
run_id: ${{ github.event.workflow_run.id }}
7055
run_number: ${{ github.event.workflow_run.run_number }}
7156
status: ${{ github.event.workflow_run.conclusion }}
72-
actor: ${{ github.actor }}
73-
repository: ${{ github.repository }}
74-
ref: ${{ github.ref }}
7557
sha: ${{ github.event.workflow_run.head_sha }}
7658

7759
pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=linux/amd64 ghcr.io/owl-corp/python-poetry-base:3.11-slim
1+
FROM --platform=linux/amd64 ghcr.io/owl-corp/python-poetry-base:3.12-slim
22

33
# Define Git SHA build argument for sentry
44
ARG git_sha="development"

bot/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from bot.bot import Bot
1414
from bot.log import get_logger, setup_sentry
1515

16-
setup_sentry()
1716
LOCALHOST = "127.0.0.1"
1817

1918

@@ -23,7 +22,6 @@ async def _create_redis_session() -> RedisSession:
2322
host=constants.Redis.host,
2423
port=constants.Redis.port,
2524
password=constants.Redis.password,
26-
max_connections=20,
2725
use_fakeredis=constants.Redis.use_fakeredis,
2826
global_namespace="bot",
2927
decode_responses=True,
@@ -36,6 +34,8 @@ async def _create_redis_session() -> RedisSession:
3634

3735
async def main() -> None:
3836
"""Entry async method for starting the bot."""
37+
setup_sentry()
38+
3939
statsd_url = constants.Stats.statsd_host
4040
if constants.DEBUG_MODE:
4141
# Since statsd is UDP, there are no errors for sending to a down port.

bot/bot.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from discord.errors import Forbidden
77
from pydis_core import BotBase
88
from pydis_core.utils.error_handling import handle_forbidden_from_block
9-
from sentry_sdk import push_scope
9+
from sentry_sdk import new_scope, start_transaction
1010

1111
from bot import constants, exts
1212
from bot.log import get_logger
@@ -29,6 +29,11 @@ def __init__(self, *args, **kwargs):
2929

3030
super().__init__(*args, **kwargs)
3131

32+
async def load_extension(self, name: str, *args, **kwargs) -> None:
33+
"""Extend D.py's load_extension function to also record sentry performance stats."""
34+
with start_transaction(op="cog-load", name=name):
35+
await super().load_extension(name, *args, **kwargs)
36+
3237
async def ping_services(self) -> None:
3338
"""A helper to make sure all the services the bot relies on are available on startup."""
3439
# Connect Site/API
@@ -66,7 +71,7 @@ async def on_error(self, event: str, *args, **kwargs) -> None:
6671

6772
self.stats.incr(f"errors.event.{event}")
6873

69-
with push_scope() as scope:
74+
with new_scope() as scope:
7075
scope.set_tag("event", event)
7176
scope.set_extra("args", args)
7277
scope.set_extra("kwargs", kwargs)

bot/constants.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
from enum import Enum
1010

11-
from pydantic import BaseModel
11+
from pydantic import BaseModel, computed_field
1212
from pydantic_settings import BaseSettings
1313

1414

@@ -138,7 +138,7 @@ class _Roles(EnvConfig, env_prefix="roles_"):
138138
lovefest: int = 542431903886606399
139139
pyweek_announcements: int = 897568414044938310
140140
revival_of_code: int = 988801794668908655
141-
legacy_help_channels_access: int = 1074780483776417964
141+
archived_channels_access: int = 1074780483776417964
142142

143143
contributors: int = 295488872404484098
144144
partners: int = 323426753857191936
@@ -322,7 +322,7 @@ class _DuckPond(EnvConfig, env_prefix="duck_pond_"):
322322

323323
threshold: int = 7
324324

325-
channel_blacklist: tuple[int, ...] = (
325+
default_channel_blacklist: tuple[int, ...] = (
326326
Channels.announcements,
327327
Channels.python_news,
328328
Channels.python_events,
@@ -336,6 +336,12 @@ class _DuckPond(EnvConfig, env_prefix="duck_pond_"):
336336
Channels.staff_info,
337337
)
338338

339+
extra_channel_blacklist: tuple[int, ...] = tuple()
340+
341+
@computed_field
342+
@property
343+
def channel_blacklist(self) -> tuple[int, ...]:
344+
return self.default_channel_blacklist + self.extra_channel_blacklist
339345

340346
DuckPond = _DuckPond()
341347

@@ -379,7 +385,7 @@ class _VideoPermission(EnvConfig, env_prefix="video_permission_"):
379385

380386
class _Redis(EnvConfig, env_prefix="redis_"):
381387

382-
host: str = "redis.default.svc.cluster.local"
388+
host: str = "redis.databases.svc.cluster.local"
383389
password: str = ""
384390
port: int = 6379
385391
use_fakeredis: bool = False # If this is True, Bot will use fakeredis.aioredis
@@ -417,8 +423,8 @@ class _Metabase(EnvConfig, env_prefix="metabase_"):
417423

418424
username: str = ""
419425
password: str = ""
420-
base_url: str = "http://metabase.default.svc.cluster.local"
421-
public_url: str = "https://metabase.pythondiscord.com"
426+
base_url: str = "http://metabase.tooling.svc.cluster.local"
427+
public_url: str = "https://metabase.pydis.wtf"
422428
max_session_age: int = 20_160
423429

424430

@@ -428,7 +434,7 @@ class _Metabase(EnvConfig, env_prefix="metabase_"):
428434
class _BaseURLs(EnvConfig, env_prefix="urls_"):
429435

430436
# Snekbox endpoints
431-
snekbox_eval_api: str = "http://snekbox.default.svc.cluster.local/eval"
437+
snekbox_eval_api: str = "http://snekbox.snekbox.svc.cluster.local/eval"
432438

433439
# Discord API
434440
discord_api: str = "https://discordapp.com/api/v7/"
@@ -438,7 +444,7 @@ class _BaseURLs(EnvConfig, env_prefix="urls_"):
438444
github_bot_repo: str = "https://github.com/python-discord/bot"
439445

440446
# Site
441-
site_api: str = "http://site.default.svc.cluster.local/api"
447+
site_api: str = "http://site.web.svc.cluster.local/api"
442448
paste_url: str = "https://paste.pythondiscord.com"
443449

444450

@@ -621,7 +627,7 @@ class _Keys(EnvConfig, env_prefix="api_keys_"):
621627
"Not likely.",
622628
"No way, José.",
623629
"Not in a million years.",
624-
"Fat chance.",
630+
"I would love to, but unfortunately... no.",
625631
"Certainly not.",
626632
"NEGATORY.",
627633
"Nuh-uh.",
@@ -655,8 +661,9 @@ class _Keys(EnvConfig, env_prefix="api_keys_"):
655661
"In the future, don't do that.",
656662
"That was a mistake.",
657663
"You blew it.",
658-
"You're bad at computers.",
659-
"Are you trying to kill me?",
664+
"Application bot.exe will be closed.",
665+
"Kernel Panic! *Kernel runs around in panic*",
666+
"Error 418. I am a teapot.",
660667
"Noooooo!!",
661668
"I can't believe you've done this",
662669
)

0 commit comments

Comments
 (0)