Skip to content

Refactor configuration #213

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

Merged
merged 17 commits into from
May 10, 2025
Merged

Refactor configuration #213

merged 17 commits into from
May 10, 2025

Conversation

NMertsch
Copy link
Contributor

@NMertsch NMertsch commented Apr 27, 2025

Fixes #139
Fixes #118
Fixes #214

Drop ansible, yarl, arrow, certifi

We don't use any of these packages. Ansible is used during deployment, but it is installed during the GitHub Action execution.

Drop python-dotenv

The program now expects the environment variables DISCORD_BOT_TOKEN and PRETIX_TOKEN without falling back to .secrets.

compose.yml now uses secrets as env-file instead of binding the file into the container.

Split configuration, use pydantic

Every cog (besides Ping) now has its own configuration class. Configuration is modelled using pydantic.BaseModel.

Refactor $participants command cog

  • Dynamically create list of roles, instead of relying on hard-coded configuration.
  • Refactor into a single-file module (like Ping) instead of multi-file extension.

Use channel names instead of IDs in config, simplify registration and program notification code

The configuration is now server-agnostic, and the code contains less indirection.

NMertsch added 9 commits May 6, 2025 19:44
General
* User __name__ as logger name everywhere

'$participants' command:
* Move from extension module to simple cog
* Use dynamic role list instead of hard-coded role names
* Add channel visibility check

bot.py
* Simplify and refactor

program notifications
* Use channel names in config, not IDs
* Simplify notification logic
* Config: Require file path explicitly
* run-bot: Expect config file path as --config-file or CONFIG_FILE
* README: Update
* uv: Remove python-dotenv and certifi dependencies
* Move config files to repo root
* Docker: Expect CONFIG_FILE
* Compose: Specify config file and .secrets
Model all configuration as cog-specific pydantic.BaseModels.
Remove certifi, yarl and arrow
@NMertsch NMertsch force-pushed the 118-config-use-names-instead-of-ids branch from 764d6f0 to aa20350 Compare May 6, 2025 17:54
@NMertsch NMertsch force-pushed the 118-config-use-names-instead-of-ids branch 2 times, most recently from 9fc013d to d30f680 Compare May 10, 2025 21:42
Use plain messages instead of embeds, use ASCII codes instead of unicode emojis
@NMertsch NMertsch force-pushed the 118-config-use-names-instead-of-ids branch from d30f680 to 4c59923 Compare May 10, 2025 21:47
@NMertsch NMertsch force-pushed the 118-config-use-names-instead-of-ids branch from 21c7ce3 to 3ca3b3e Compare May 10, 2025 22:05
@NMertsch NMertsch force-pushed the 118-config-use-names-instead-of-ids branch from 3ca3b3e to df49599 Compare May 10, 2025 22:06
@NMertsch NMertsch force-pushed the 118-config-use-names-instead-of-ids branch from 1aa519e to 84ff839 Compare May 10, 2025 22:12
@NMertsch NMertsch merged commit 5c118f0 into main May 10, 2025
5 checks passed
@NMertsch NMertsch deleted the 118-config-use-names-instead-of-ids branch May 10, 2025 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant