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 : ## Launcher requirements :
- [ ] Can install the bot - [ ] Can install the bot
- [x] Can launch the bot - [ ] Can launch the bot
- [x] Can propose updates - [ ] Can propose updates
## New commands : ## New commands :
@ -27,7 +27,7 @@
## Ultimate : ## Ultimate :
- [ ] Send email or Telegram's message when something is wrong on the bot - [ ] 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 (help?)
- [ ] ci show - [ ] ci show
- [ ] ci register - [ ] ci register

12
bot.py
View file

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

View file

@ -372,9 +372,9 @@ class Admin(commands.Cog):
@_warn.command(name='remove', aliases=['revoke']) @_warn.command(name='remove', aliases=['revoke'])
async def _warn_remove(self, ctx: commands.Context, warn_id: int): async def _warn_remove(self, ctx: commands.Context, warn_id: int):
warn = self.bot.database.session\ warn = self.bot.database.session \
.query(Warn)\ .query(Warn) \
.filter(Warn.id == warn_id)\ .filter(Warn.id == warn_id) \
.one() .one()
self.bot.database.session.delete(warn) self.bot.database.session.delete(warn)
@ -395,9 +395,9 @@ class Admin(commands.Cog):
@_warn.command(name='edit', aliases=['change']) @_warn.command(name='edit', aliases=['change'])
async def _warn_edit(self, ctx: commands.Context, warn_id: int, *, reason): async def _warn_edit(self, ctx: commands.Context, warn_id: int, *, reason):
warn = self.bot.database.session\ warn = self.bot.database.session \
.query(Warn)\ .query(Warn) \
.filter(Warn.id == warn_id)\ .filter(Warn.id == warn_id) \
.one() .one()
warn.reason = reason warn.reason = reason
@ -413,8 +413,8 @@ class Admin(commands.Cog):
available = self.bot.database.session \ available = self.bot.database.session \
.query(Lang.value) \ .query(Lang.value) \
.filter(Lang.key == 'available') \ .filter(Lang.key == 'available') \
.one()[0] \ .first()[0] \
.split(', ') .split(',')
if locale.lower() not in available: if locale.lower() not in available:
await ctx.send( await ctx.send(

View file

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