update(command|info): add git to link's field

This commit is contained in:
Romain J 2019-12-16 19:36:55 +01:00
parent e7d4a9ee43
commit d5afdcc60b
9 changed files with 51 additions and 20 deletions

View file

@ -12,8 +12,8 @@
## Launcher requirements :
- [ ] Can install the bot
- [x] Can launch the bot
- [x] Can propose updates
- [ ] Can launch the bot
- [ ] Can propose updates
## New commands :
@ -27,7 +27,7 @@
## Ultimate :
- [ ] Send email or Telegram's message when something is wrong on the bot
- [ ] Create skynet (group of multiple commands about sky (planes, meteo,...))
- [ ] Create skynet (group of multiple commands about sky (planes, meteo, AI,...))
---
@ -57,7 +57,7 @@
---
# Cogs.ci commands
# Cogs.ci commands `canceled until the frontend development`
- [ ] ci (help?)
- [ ] ci show
- [ ] ci register

12
bot.py
View file

@ -10,6 +10,7 @@ import discord
import git
from discord.ext import commands
from cogs.utils.database import Database
from cogs.utils.config import Config
from cogs.utils.lang import Texts
from cogs.utils.version import Version
@ -22,10 +23,10 @@ build = git.Repo(search_parent_directories=True).head.object.hexsha
log = logging.getLogger(__name__)
l_extensions: List[str] = [
'cogs.admin',
# 'cogs.admin',
'cogs.basics',
'cogs.utility',
'cogs.logs',
# 'cogs.utility',
# 'cogs.logs',
# 'cogs.poll',
'jishaku',
]
@ -46,7 +47,7 @@ async def _prefix_callable(bot, message: discord.message) -> list:
class TuxBot(commands.AutoShardedBot):
def __init__(self):
def __init__(self, database):
super().__init__(command_prefix=_prefix_callable, pm_help=None,
help_command=None, description=description,
help_attrs=dict(hidden=True),
@ -60,6 +61,7 @@ class TuxBot(commands.AutoShardedBot):
self.uptime: datetime = datetime.datetime.utcnow()
self._prev_events = deque(maxlen=10)
self.session = aiohttp.ClientSession(loop=self.loop)
self.database = database
self.config = Config('./configs/config.cfg')
self.prefixes = Config('./configs/prefixes.cfg')
@ -189,7 +191,7 @@ if __name__ == "__main__":
print(Texts().get('Starting...'))
bot = TuxBot()
bot = TuxBot(Database(Config("./configs/config.cfg")))
try:
with setup_logging():
bot.run()

View file

@ -413,7 +413,7 @@ class Admin(commands.Cog):
available = self.bot.database.session \
.query(Lang.value) \
.filter(Lang.key == 'available') \
.one()[0] \
.first()[0] \
.split(',')
if locale.lower() not in available:

View file

@ -10,6 +10,7 @@ from discord.ext import commands
from bot import TuxBot
from .utils.lang import Texts
from .utils.extra import commandExtra, groupExtra
from tcp_latency import measure_latency
@ -26,7 +27,9 @@ class Basics(commands.Cog):
"""---------------------------------------------------------------------"""
@commands.command(name='ping')
@commandExtra(name='ping',
category='basics',
description=Texts('commands').get('basics.ping'))
async def _ping(self, ctx: commands.Context):
start = time.perf_counter()
await ctx.trigger_typing()
@ -64,7 +67,9 @@ class Basics(commands.Cog):
return total, file_amount
@commands.command(name='info', aliases=['about'])
@commands.command(name='info', aliases=['about'],
category='basics',
description=Texts('commands').get('basics.info'))
async def _info(self, ctx: commands.Context):
proc = psutil.Process()
lines, files = self.fetch_info()
@ -133,6 +138,7 @@ class Basics(commands.Cog):
name=f"__:link: {Texts('basics', ctx).get('Links')}__",
value="[tuxbot.gnous.eu](https://tuxbot.gnous.eu/) "
"| [gnous.eu](https://gnous.eu/) "
"| [git](https://git.gnous.eu/gnouseu/tuxbot-bot) "
f"| [{Texts('basics', ctx).get('Invite')}](https://discordapp.com/oauth2/authorize?client_id=301062143942590465&scope=bot&permissions=268749888)",
inline=False
)
@ -144,7 +150,9 @@ class Basics(commands.Cog):
"""---------------------------------------------------------------------"""
@commands.command(name='credits', aliases=['contributors', 'authors'])
@commands.command(name='credits', aliases=['contributors', 'authors'],
category='basics',
description=Texts('commands').get('basics.credits'))
async def _credits(self, ctx: commands.Context):
e = discord.Embed(
title=Texts('basics', ctx).get('Contributors'),

21
cogs/utils/extra.py Normal file
View file

@ -0,0 +1,21 @@
from discord.ext import commands
class commandsPlus(commands.Command):
def __init__(self, func, **kwargs):
super().__init__(func, **kwargs)
self.category = kwargs.pop("category")
def commandExtra(*args, **kwargs):
return commands.command(*args, **kwargs, cls=commandsPlus)
class GroupPlus(commands.Group):
def __init__(self, func, **kwargs):
super().__init__(func, **kwargs)
self.category = kwargs.pop("category")
def groupExtra(*args, **kwargs):
return commands.group(*args, **kwargs, cls=GroupPlus)

Binary file not shown.

Binary file not shown.