-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trois fichiers actualisés selon les normes Codacy.
- Loading branch information
Showing
3 changed files
with
24 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |