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

🧱 feat(config): Réécriture de la configuration #53

Closed
wants to merge 3 commits into from

Conversation

ascpial
Copy link
Contributor

@ascpial ascpial commented Sep 10, 2022

Cette PR a pour but d'écrire un nouveau système de configuration pour être à la fois plus simple pour débuter et plus puissant avec une utilisation avancée.

Le fichier affecté pour le moment par la réécriture est indépendant du reste du projet.
Je commencerais à modifier les plugins pour fonctionner avec ce système quand il sera mature.

Pour voir l'état actuel de l'écriture du nouveau système de configuration, vous pouvez aller voir l'exemple contenu à la fin du fichier bot/config.py.

Je met ici ce qu'il est possible de faire avec le système mais je ne garantie pas qu'il sera à jour :

# géré par le cœur, qui charge les fichiers comme il veut
# le développeur de plugin doit ne pas avoir à toucher à ces initialisations
config1 = Configuration(is_child=False)
config1.load("test.yaml")

# si le développeur a vraiment la flemme mais une flemme paradoxale, il
# peut accéder à la configuration comme ceci
print(config1["ban"]["friendly_ban"])

# cette partie est le minimum syndicale pour le développeur
ban_config_1 = Configuration(namespace="ban")
config1.add_configuration_child(ban_config_1)

# à partir de là le développeur peut accéder à la configuration comme suit
print(ban_config_1['friendly_ban'])
# on est d'accord que c'est plus propre que ce qui est affiché plus haut

# nouvelle exemple

config2 = Configuration(is_child=False)
config2.load("test.yaml")

# le développeur de plugin peut aussi ajouter les champs en tant que variable
class BanConfiguration(Configuration):
    friendly_ban = ConfigurationField(bool) # on pourra définir le type, avoir une conversion des données, mettre une valeur par défaut etc à terme

# les mêmes étapes que plus haut (le *minimum syndical*)
ban_config_2 = BanConfiguration("ban")
config2.add_configuration_child(ban_config_2)

# et pouf ça fait des chocapic
print(ban_config_2.friendly_ban)
# encore plus propre que plus haut non ?
# et ça supporte le typage avec par ex vscode ! (si tu spécifie un type)

@ascpial ascpial closed this Sep 10, 2022
@ascpial ascpial deleted the config-test branch September 10, 2022 21:07
Aeris1One pushed a commit that referenced this pull request Apr 25, 2023
* V4.3.0 (#45)

* fix(readme): dead badge

* fix(stats): merge failure

* feat(antiscam): improve regex matching

* feat(antiscam): improve training logs

* fix(check): config reset bypass ignored guilds

* fix(rss): DM commands + no tweet found

* refract(stats): remove statuspage RAM usage

* fix(yt): new youtube channel URL

* refract(xp): better logs

* fix(antiscam): regex replacement

* feat(antiscam): improve training/saving process

* fix(roles-react): deleted custom emoji

* refract(tokens): improve credentials fetching

* fix(top.gg): API stats posting for axobot

* refract: rename Zbot class to Axobot

* refract(doc): rename Zbot to Axobot in doc

* refract(errors): variable name

* fix(args): circular import

* fix(logs): message update with pin/unpin

* fix(twitch): log when loop fails

* fix(help): config fetching

* feat(serverconfig): 1st version of the new system

* feat(serverconfig): update every config call

* fix(serverconfig): xp stats

* refract(alias): avoid using ctx.invoke

* feat(doc): refresh documentation

* feat(doc): use spinx book theme

* fix(doc): references and tocdepth

* fix(doc): dependencies list

* feat(doc): v4.3.0

* feat(config): french translations

* feat(modlogs): add msg creation time when deleted

* fix(find): rss with NUL date

* fix(error): slash command name

* fix(logs): difference between nick and username

* New Crowdin updates (#44)

* Update source file en.json

* Update source file en.json

* Update source file en.json

* feat(actions): upgrade to checkout v3

* fix(admin): update command

* fix(logs): database backup detection

* feat(tr): new guild features translations

* fix(doc): `config change` being renamed to `set`

* rmv(prefix): `prefix change` subcommand

* feat(fun): re-enable weather command

* fix(help): not working in DMs

* fix(logs): DM logs with nearly 2k characters

* fix(prefix): make it a command instead of group

* feat(tickets): better error when fails to create

* feat(tickets): add `tickets review-config` cmd

* feat(doc): v4.3.1

* fix(doc): typo in "antiscam" server logs

* feat(rss): use paginator for rss list

* refract(paginator): faster view refresh

* refract(rss): cap list to 10 feeds/page

* refract(pagination): better disabling workflow

* fix(xp): always disabled

* fix(xp): always disabled

* fix(xp): levelup channel config

* fix(xp): levelup channel config

* New Crowdin updates (#47)

* Update source file en.json

* Update source file en.json

* fix(xp): levelup check

* fix(xp): levelup check

* fix(memberchannel): error log

* feat(serverlogs): add tickets errors

* feat(doc): emojis and cards

* feat(reminder): new creation example

* feat(deps): update LRFutils

* fix(error): help command mention

* feat(modlogs): add role deletion

* feat(serverlogs): role_update logs

* feat(xp): private rank command

* fix(db): remote connection

* fix(xp): font usage

* Create .github/FUNDING.yml

* refract(ticket): better ticket summary text

* refract(serverlogs): factorise audit logs search

* feat(slash): migrate about command

* feat(usernames): disable usernames history feature

* fix(sconfig): hidden config options

* feat(stats): save audit logs search success rate

* feat(slash): migrate remindme command

* refract(lint): remove unusued import

* refract(lint): add missing space

* feat(tips): add rank card background tip

* feat(tips): implement cache

* feat(tips): lower rank card tip probability

* feat(crowdin): better commit message

* Revert "feat(crowdin): better commit message"

This reverts commit 6b9f52f.

* New Crowdin updates (#48)

* Update source file en.json

* Update source file en.json

* New translations en.json (LOLCAT)

* New translations en.json (LOLCAT)

* New translations en.json (LOLCAT)

* New translations en.json (LOLCAT)

* Update source file en.json

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* Update translations %original_path% (%language%)

* Update translations %original_path% (Finnish)

* Update translations %original_path% (LOLCAT)

* Update translations %original_path% (Spanish)

* feat(readme): update d.py version badge

* feat(doc): update `profile` cmd doc

* feat(git): update pre-commits actions

* refract(requirements): cleanup requirements file

* feat(lint): cleanup all files

* feat(slash): migrate profile command

* feat(error): avoid truncating the traceback

* fix(clear): users check

* fix(mc): server status JSON error

* refract(user): cleaner user config change+query

* feat(tips): disable card tip if already changed

* Update source file en.json (#50)

* V4.3.1 (#51)

* fix(logs): database backup detection

* feat(tr): new guild features translations

* fix(doc): `config change` being renamed to `set`

* rmv(prefix): `prefix change` subcommand

* feat(fun): re-enable weather command

* fix(help): not working in DMs

* fix(logs): DM logs with nearly 2k characters

* fix(prefix): make it a command instead of group

* feat(tickets): better error when fails to create

* feat(tickets): add `tickets review-config` cmd

* feat(doc): v4.3.1

* fix(doc): typo in "antiscam" server logs

* feat(rss): use paginator for rss list

* refract(paginator): faster view refresh

* refract(rss): cap list to 10 feeds/page

* refract(pagination): better disabling workflow

* fix(xp): always disabled

* fix(xp): levelup channel config

* New Crowdin updates (#47)

* Update source file en.json

* Update source file en.json

* fix(xp): levelup check

* fix(memberchannel): error log

* feat(serverlogs): add tickets errors

* feat(doc): emojis and cards

* feat(reminder): new creation example

* feat(deps): update LRFutils

* fix(error): help command mention

* feat(modlogs): add role deletion

* feat(serverlogs): role_update logs

* feat(xp): private rank command

* fix(db): remote connection

* fix(xp): font usage

* Create .github/FUNDING.yml

* refract(ticket): better ticket summary text

* refract(serverlogs): factorise audit logs search

* feat(slash): migrate about command

* feat(usernames): disable usernames history feature

* fix(sconfig): hidden config options

* feat(stats): save audit logs search success rate

* feat(slash): migrate remindme command

* refract(lint): remove unusued import

* refract(lint): add missing space

* feat(tips): add rank card background tip

* feat(tips): implement cache

* feat(tips): lower rank card tip probability

* feat(crowdin): better commit message

* Revert "feat(crowdin): better commit message"

This reverts commit 6b9f52f.

* New Crowdin updates (#48)

* Update source file en.json

* Update source file en.json

* New translations en.json (LOLCAT)

* New translations en.json (LOLCAT)

* New translations en.json (LOLCAT)

* New translations en.json (LOLCAT)

* Update source file en.json

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* New translations en.json (Finnish)

* Update translations %original_path% (%language%)

* Update translations %original_path% (Finnish)

* Update translations %original_path% (LOLCAT)

* Update translations %original_path% (Spanish)

* feat(readme): update d.py version badge

* feat(doc): update `profile` cmd doc

* feat(git): update pre-commits actions

* refract(requirements): cleanup requirements file

* feat(lint): cleanup all files

* feat(slash): migrate profile command

* feat(error): avoid truncating the traceback

* fix(clear): users check

* fix(mc): server status JSON error

* refract(user): cleaner user config change+query

* feat(tips): disable card tip if already changed

* Update source file en.json (#50)

* refract(action): update CodeQL triggers

* feat(doc): update documentation URLs

* fix(usernames): disable new usernames storing

* feat(rank): delete invocation for private rankcard

* fix(config): code using old table

* fix(stats): antiscam enabled count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant