Skip to content

Commit

Permalink
Trois fichiers actualisés selon les normes Codacy.
Browse files Browse the repository at this point in the history
  • Loading branch information
S2P-KB committed Jun 28, 2024
1 parent 8c30163 commit a1dc410
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
28 changes: 16 additions & 12 deletions src/bot/cog_General.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
from discord.ext import commands
import bot
from bot import localization, _, strings
from Bot_Base.src.urpy.localization import Localization
from Bot_Base.src.urpy.my_commands import MyBot
import strings
import urpy

#UR_Bot © 2020 by "Association Union des Rôlistes & co" is licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA)
#To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/
#Ask a derogation at [email protected]
# UR_Bot © 2020 by "Association Union des Rôlistes & co" is licensed under Attribution-NonCommercial-ShareAlike 4.0
# International (CC BY-NC-SA). To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/
# Ask a derogation at [email protected]


class General(commands.Cog):
"""Cog contenant des commandes générales pour le bot."""
__doc__ = strings.General_descr

def __init__(self, URBot: urpy.MyBot):
self.bot = URBot
def __init__(self, ur_bot: MyBot):
"""Initialise une instance spécifiée plus haut."""
self.bot = ur_bot
self.callbacks = {
'edit': [],
'done': [],
'cancel': []
}

async def call_callbacks(self, command: str, ctx: commands.Context):
"""Appelle-les callbacks liés à une commande spécifique."""
for callback in self.callbacks[command]:
await callback(ctx)

Expand All @@ -41,14 +45,14 @@ async def cancel(self, ctx):
@commands.command(brief=strings.lang_brief, help=strings.lang_help)
async def lang(self, ctx: commands.Context, language):
""" Switches to specified language """
if language in localization.languages:
localization.set_user_language(language)
await ctx.send(_("Your language has successfully been set to english !"))
if language in Localization.languages: # erreur, car la classe 'languages' n'existe pas, il faut la créer.
Localization.set_user_language(language)
await ctx.send(_("Your language has successfully been set to english !")) # même erreur trois lignes avant

else:
await ctx.send(_("Sorry, i don't know this language !"))
await ctx.send(_("Sorry, i don't know this language !")) # même erreur trois lignes avant

def add_to_command(self, command: str, *callbacks):
""" Adds a callback to the specified command. It will be called on command invokation."""
""" Adds a callback to the specified command. It will be called on command invocation."""
for callback in callbacks:
self.callbacks[command].append(callback)
5 changes: 4 additions & 1 deletion src/bot/settings.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
command_prefix = '$'
COMMAND_PREFIX = '$'
"""
Préfixe utilisé par le bot. C'est ce qui lui permet de reconnaître les commandes tapées par l'utilisateur.
"""
5 changes: 4 additions & 1 deletion src/start.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/opt/virtualenv/URBot/bin/python
#!/opt/virtualenv/ur_bot/bin/python
from bot.URbot import main

if __name__ == '__main__':
"""
Démarrage du programme.
"""
main()

0 comments on commit a1dc410

Please sign in to comment.