some minor changes in few things

This commit is contained in:
Romain J 2020-01-15 00:08:53 +01:00
parent d187177908
commit b7ed8ffae7
24 changed files with 156 additions and 211 deletions

2
bot.py
View file

@ -29,7 +29,7 @@ l_extensions: List[str] = [
'cogs.Help', 'cogs.Help',
'cogs.Logs', 'cogs.Logs',
# 'cogs.Monitoring', # 'cogs.Monitoring',
'cogs.Polls', 'cogs.Poll',
'cogs.Useful', 'cogs.Useful',
'cogs.User', 'cogs.User',
'jishaku', 'jishaku',

View file

@ -65,10 +65,7 @@ class Admin(commands.Cog):
########################################################################### ###########################################################################
@groupExtra(name='say', invoke_without_command=True, category='text', @groupExtra(name='say', invoke_without_command=True, category='text')
description=Texts('admin_help').get('_say'),
help=Texts('admin_help').get('_say__short'),
usage=Texts('admin_help').get('_say__usage'))
async def _say(self, ctx: commands.Context, *, content: str): async def _say(self, ctx: commands.Context, *, content: str):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
try: try:
@ -78,10 +75,7 @@ class Admin(commands.Cog):
await ctx.send(content) await ctx.send(content)
@_say.command(name='edit', @_say.command(name='edit')
description=Texts('admin_help').get('_say_edit'),
help=Texts('admin_help').get('_say_edit__short'),
usage=Texts('admin_help').get('_say_edit__usage'))
async def _say_edit(self, ctx: commands.Context, message_id: int, *, async def _say_edit(self, ctx: commands.Context, message_id: int, *,
content: str): content: str):
try: try:
@ -98,10 +92,7 @@ class Admin(commands.Cog):
Texts('utils', ctx).get("Unable to find the message"), Texts('utils', ctx).get("Unable to find the message"),
delete_after=5) delete_after=5)
@_say.command(name='to', @_say.command(name='to')
description=Texts('admin_help').get('_say_to'),
help=Texts('admin_help').get('_say_to__short'),
usage=Texts('admin_help').get('_say_to__usage'))
async def _say_to(self, ctx: commands.Context, async def _say_to(self, ctx: commands.Context,
channel: Union[discord.TextChannel, discord.User], *, channel: Union[discord.TextChannel, discord.User], *,
content): content):
@ -114,10 +105,7 @@ class Admin(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='ban', category='administration', @commandExtra(name='ban', category='administration')
description=Texts('admin_help').get('_ban'),
help=Texts('admin_help').get('_ban__short'),
usage=Texts('admin_help').get('_ban__usage'))
async def _ban(self, ctx: commands.Context, user: discord.Member, *, async def _ban(self, ctx: commands.Context, user: discord.Member, *,
reason=""): reason=""):
try: try:
@ -144,10 +132,7 @@ class Admin(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='kick', category='administration', @commandExtra(name='kick', category='administration')
description=Texts('admin_help').get('_kick'),
help=Texts('admin_help').get('_kick__short'),
usage=Texts('admin_help').get('_kick__usage'))
async def _kick(self, ctx: commands.Context, user: discord.Member, *, async def _kick(self, ctx: commands.Context, user: discord.Member, *,
reason=""): reason=""):
try: try:
@ -174,10 +159,7 @@ class Admin(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='clear', category='text', @commandExtra(name='clear', category='text')
description=Texts('admin_help').get('_clear'),
help=Texts('admin_help').get('_clear__short'),
usage=Texts('admin_help').get('_clear__usage'))
async def _clear(self, ctx: commands.Context, count: int): async def _clear(self, ctx: commands.Context, count: int):
try: try:
await ctx.message.delete() await ctx.message.delete()
@ -187,18 +169,12 @@ class Admin(commands.Cog):
########################################################################### ###########################################################################
@groupExtra(name='react', category='text', @groupExtra(name='react', category='text')
description=Texts('admin_help').get('_react'),
help=Texts('admin_help').get('_react__short'),
usage=Texts('admin_help').get('_react__usage'))
async def _react(self, ctx: commands.Context): async def _react(self, ctx: commands.Context):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help('react') await ctx.send_help('react')
@_react.command(name='add', @_react.command(name='add')
description=Texts('admin_help').get('_react_add'),
help=Texts('admin_help').get('_react_add__short'),
usage=Texts('admin_help').get('_react_add__usage'))
async def _react_add(self, ctx: commands.Context, message_id: int, *, async def _react_add(self, ctx: commands.Context, message_id: int, *,
emojis: str): emojis: str):
emojis: list = emojis.split(' ') emojis: list = emojis.split(' ')
@ -214,10 +190,7 @@ class Admin(commands.Cog):
Texts('utils', ctx).get("Unable to find the message"), Texts('utils', ctx).get("Unable to find the message"),
delete_after=5) delete_after=5)
@_react.command(name='clear', @_react.command(name='remove', aliases=['clear'])
description=Texts('admin_help').get('_react_remove'),
help=Texts('admin_help').get('_react_remove__short'),
usage=Texts('admin_help').get('_react_remove__usage'))
async def _react_remove(self, ctx: commands.Context, message_id: int): async def _react_remove(self, ctx: commands.Context, message_id: int):
try: try:
message: discord.Message = await ctx.channel.fetch_message( message: discord.Message = await ctx.channel.fetch_message(
@ -230,11 +203,7 @@ class Admin(commands.Cog):
########################################################################### ###########################################################################
@groupExtra(name='delete', invoke_without_command=True, @groupExtra(name='delete', invoke_without_command=True, category='text')
category='text',
description=Texts('admin_help').get('_delete'),
help=Texts('admin_help').get('_delete__short'),
usage=Texts('admin_help').get('_delete___usage'))
async def _delete(self, ctx: commands.Context, message_id: int): async def _delete(self, ctx: commands.Context, message_id: int):
try: try:
await ctx.message.delete() await ctx.message.delete()
@ -250,10 +219,7 @@ class Admin(commands.Cog):
Texts('utils', ctx).get("Unable to find the message"), Texts('utils', ctx).get("Unable to find the message"),
delete_after=5) delete_after=5)
@_delete.command(name='from', aliases=['to', 'in'], @_delete.command(name='from', aliases=['to', 'in'])
description=Texts('admin_help').get('_delete_from'),
help=Texts('admin_help').get('_delete_from__short'),
usage=Texts('admin_help').get('_delete_from__usage'))
async def _delete_from(self, ctx: commands.Context, async def _delete_from(self, ctx: commands.Context,
channel: discord.TextChannel, message_id: int): channel: discord.TextChannel, message_id: int):
try: try:
@ -317,10 +283,7 @@ class Admin(commands.Cog):
self.bot.database.session.add(warn) self.bot.database.session.add(warn)
self.bot.database.session.commit() self.bot.database.session.commit()
@groupExtra(name='warn', aliases=['warns'], category='administration', @groupExtra(name='warn', aliases=['warns'], category='administration')
description=Texts('admin_help').get('_warn'),
help=Texts('admin_help').get('_warn__short'),
usage=Texts('admin_help').get('_warn__usage'))
async def _warn(self, ctx: commands.Context): async def _warn(self, ctx: commands.Context):
await ctx.trigger_typing() await ctx.trigger_typing()
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
@ -332,11 +295,8 @@ class Admin(commands.Cog):
await ctx.send(embed=e) await ctx.send(embed=e)
@_warn.command(name='add', aliases=['new'], @_warn.command(name='add', aliases=['new'])
description=Texts('admin_help').get('_warn_new'), async def _warn_add(self, ctx: commands.Context, member: discord.Member,
help=Texts('admin_help').get('_warn_new__short'),
usage=Texts('admin_help').get('_warn_new__usage'))
async def _warn_new(self, ctx: commands.Context, member: discord.Member,
*, reason="N/A"): *, reason="N/A"):
member = await ctx.guild.fetch_member(member.id) member = await ctx.guild.fetch_member(member.id)
if not member: if not member:
@ -414,10 +374,7 @@ class Admin(commands.Cog):
f"\n**{Texts('admin', ctx).get('Reason')}:** `{reason}`" f"\n**{Texts('admin', ctx).get('Reason')}:** `{reason}`"
) )
@_warn.command(name='remove', aliases=['revoke', 'del', 'delete'], @_warn.command(name='remove', aliases=['revoke', 'del', 'delete'])
description=Texts('admin_help').get('_warn_remove'),
help=Texts('admin_help').get('_warn_remove__short'),
usage=Texts('admin_help').get('_warn_remove__usage'))
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(WarnModel) \ .query(WarnModel) \
@ -429,10 +386,7 @@ class Admin(commands.Cog):
await ctx.send(f"{Texts('admin', ctx).get('Warn with id')} `{warn_id}`" await ctx.send(f"{Texts('admin', ctx).get('Warn with id')} `{warn_id}`"
f" {Texts('admin', ctx).get('successfully removed')}") f" {Texts('admin', ctx).get('successfully removed')}")
@_warn.command(name='show', aliases=['list', 'all'], @_warn.command(name='show', aliases=['list', 'all'])
description=Texts('admin_help').get('_warn_show'),
help=Texts('admin_help').get('_warn_show__short'),
usage=Texts('admin_help').get('_warn_show__usage'))
async def _warn_show(self, ctx: commands.Context, member: discord.Member): async def _warn_show(self, ctx: commands.Context, member: discord.Member):
warns_list, warns = await self.get_warn(ctx, member) warns_list, warns = await self.get_warn(ctx, member)
@ -443,10 +397,7 @@ class Admin(commands.Cog):
await ctx.send(embed=e) await ctx.send(embed=e)
@_warn.command(name='edit', aliases=['change', 'modify'], @_warn.command(name='edit', aliases=['change', 'modify'])
description=Texts('admin_help').get('_warn_edit'),
help=Texts('admin_help').get('_warn_edit__short'),
usage=Texts('admin_help').get('_warn_edit__usage'))
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(WarnModel) \ .query(WarnModel) \
@ -461,11 +412,7 @@ class Admin(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='language', aliases=['lang', 'langue', 'langage'], @commandExtra(name='language', aliases=['lang', 'langue', 'langage'], category='server')
category='server',
description=Texts('admin_help').get('_language'),
help=Texts('admin_help').get('_language__short'),
usage=Texts('admin_help').get('_language__usage'))
async def _language(self, ctx: commands.Context, locale: str): async def _language(self, ctx: commands.Context, locale: str):
available = self.bot.database.session \ available = self.bot.database.session \
.query(LangModel.value) \ .query(LangModel.value) \
@ -496,18 +443,12 @@ class Admin(commands.Cog):
########################################################################### ###########################################################################
@groupExtra(name='prefix', aliases=['prefixes'], category='server', @groupExtra(name='prefix', aliases=['prefixes'], category='server')
description=Texts('admin_help').get('_prefix'),
help=Texts('admin_help').get('_prefix_short'),
usage=Texts('admin_help').get('_prefix__usage'))
async def _prefix(self, ctx: commands.Context): async def _prefix(self, ctx: commands.Context):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help('prefix') await ctx.send_help('prefix')
@_prefix.command(name='add', aliases=['set', 'new'], @_prefix.command(name='add', aliases=['set', 'new'])
description=Texts('admin_help').get('_prefix_add'),
help=Texts('admin_help').get('_prefix_add__short'),
usage=Texts('admin_help').get('_prefix_add__usage'))
async def _prefix_add(self, ctx: commands.Context, prefix: str): async def _prefix_add(self, ctx: commands.Context, prefix: str):
if str(ctx.guild.id) in self.bot.prefixes: if str(ctx.guild.id) in self.bot.prefixes:
prefixes = self.bot.prefixes.get( prefixes = self.bot.prefixes.get(
@ -540,10 +481,7 @@ class Admin(commands.Cog):
Texts('admin', ctx).get('Prefix added successfully') Texts('admin', ctx).get('Prefix added successfully')
) )
@_prefix.command(name='remove', aliases=['drop', 'del', 'delete'], @_prefix.command(name='remove', aliases=['drop', 'del', 'delete'])
description=Texts('admin_help').get('_prefix_remove'),
help=Texts('admin_help').get('_prefix_remove__short'),
usage=Texts('admin_help').get('_prefix_remove__usage'))
async def _prefix_remove(self, ctx: commands.Context, prefix: str): async def _prefix_remove(self, ctx: commands.Context, prefix: str):
if str(ctx.guild.id) in self.bot.prefixes: if str(ctx.guild.id) in self.bot.prefixes:
prefixes = self.bot.prefixes.get( prefixes = self.bot.prefixes.get(
@ -571,10 +509,7 @@ class Admin(commands.Cog):
Texts('admin', ctx).get('This prefix does not exist') Texts('admin', ctx).get('This prefix does not exist')
) )
@_prefix.command(name='list', aliases=['show', 'all'], @_prefix.command(name='list', aliases=['show', 'all'])
description=Texts('admin_help').get('_prefix_list'),
help=Texts('admin_help').get('_prefix_list__short'),
usage=Texts('admin_help').get('_prefix_list__usage'))
async def _prefix_list(self, ctx: commands.Context): async def _prefix_list(self, ctx: commands.Context):
extras = ['.'] extras = ['.']
if ctx.message.guild is not None: if ctx.message.guild is not None:

View file

@ -19,12 +19,21 @@ class HelpCommand(commands.HelpCommand):
self.owner_cogs = [] self.owner_cogs = []
self.admin_cogs = ["Admin"] self.admin_cogs = ["Admin"]
def common_command_formatting(self, e, command): def command_formatting(self, e, command):
prefix = self.context.prefix if str( prefix = self.context.prefix \
self.context.bot.user.id) not in self.context.prefix else f"@{self.context.bot.user.name}" if str(self.context.bot.user.id) not in self.context.prefix \
else f"@{self.context.bot.user.name}"
file = Texts(command.cog.qualified_name.lower() + '_help', self.context)
e.title = self.get_command_signature(command) if command.parent is not None:
e.description = command.description description = file.get(f"_{command.parent}_{command.name}")
usage = file.get(f"_{command.parent}_{command.name}__usage")
else:
description = file.get(f"_{command.name}")
usage = file.get(f"_{command.name}__usage")
e.title = self.get_command_signature(command) + usage
e.description = description
e.add_field( e.add_field(
name=Texts( name=Texts(
@ -32,7 +41,7 @@ class HelpCommand(commands.HelpCommand):
).get( ).get(
'command_help.params' 'command_help.params'
), ),
value=command.usage value=usage
) )
e.add_field( e.add_field(
name=Texts( name=Texts(
@ -40,7 +49,7 @@ class HelpCommand(commands.HelpCommand):
).get( ).get(
'command_help.usage' 'command_help.usage'
), ),
value=f"{prefix}{command.qualified_name} " + command.usage value=f"{prefix}{command.qualified_name} " + usage
) )
aliases = "`" + '`, `'.join(command.aliases) + "`" aliases = "`" + '`, `'.join(command.aliases) + "`"
@ -63,12 +72,9 @@ class HelpCommand(commands.HelpCommand):
async def send_bot_help(self, mapping): async def send_bot_help(self, mapping):
owners = self.context.bot.owners owners = self.context.bot.owners
owners_name = [ prefix = self.context.prefix \
f"{owner.name}#{owner.discriminator}" if str(self.context.bot.user.id) not in self.context.prefix \
for owner in owners else f"@{self.context.bot.user.name} "
]
prefix = self.context.prefix if str(
self.context.bot.user.id) not in self.context.prefix else f"@{self.context.bot.user.name} "
e = discord.Embed( e = discord.Embed(
color=discord.Color.blue(), color=discord.Color.blue(),
@ -76,8 +82,6 @@ class HelpCommand(commands.HelpCommand):
'help', self.context 'help', self.context
).get( ).get(
'main_page.description' 'main_page.description'
).format(
', '.join(owners_name[:-1]) + ' & ' + owners_name[-1]
) )
) )
e.set_author( e.set_author(
@ -116,8 +120,10 @@ class HelpCommand(commands.HelpCommand):
async def send_cog_help(self, cog): async def send_cog_help(self, cog):
pages = {} pages = {}
prefix = self.context.prefix if str( prefix = self.context.prefix \
self.context.bot.user.id) not in self.context.prefix else f"@{self.context.bot.user.name}" if str(self.context.bot.user.id) not in self.context.prefix \
else f"@{self.context.bot.user.name}"
file = Texts(cog.qualified_name.lower() + '_help', self.context)
if cog.__class__.__name__ in self.owner_cogs \ if cog.__class__.__name__ in self.owner_cogs \
and self.context.author not in self.context.bot.owners: and self.context.author not in self.context.bot.owners:
@ -133,15 +139,15 @@ class HelpCommand(commands.HelpCommand):
pages[cmd.category] \ pages[cmd.category] \
+= f"{cmd.name}" \ += f"{cmd.name}" \
+ ' ' * int(17 - len(cmd.name)) \ + ' ' * int(13 - len(cmd.name)) \
+ f":: {cmd.help}\n" + f":: {file.get(f'_{cmd.name}__short')}\n"
if isinstance(cmd, GroupPlus): if isinstance(cmd, GroupPlus):
for group_command in cmd.commands: for group_command in cmd.commands:
pages[cmd.category] \ pages[cmd.category] \
+= f"└> {group_command.name}" \ += f"└> {group_command.name}" \
+ ' ' * int(15 - len(group_command.name)) \ + ' ' * int(10 - len(group_command.name)) \
+ f":: {group_command.help}\n" + f":: {file.get(f'_{group_command.parent}_{group_command.name}__short')}\n"
for e in pages: for e in pages:
pages[e] += "```" pages[e] += "```"
formatted = [] formatted = []
@ -168,21 +174,23 @@ class HelpCommand(commands.HelpCommand):
return await self.send_error_message( return await self.send_error_message(
self.command_not_found(group.name) self.command_not_found(group.name)
) )
file = Texts(group.qualified_name.lower() + '_help', self.context)
formatted = self.common_command_formatting( formatted = self.command_formatting(
discord.Embed(color=discord.Color.blue()), discord.Embed(color=discord.Color.blue()),
group group
) )
sub_cmd_list = "" sub_command_list = "" # this is braille, please don't touch unless you know what you're doing
for group_command in group.commands: for group_command in group.commands:
sub_cmd_list += f"└> **{group_command.name}** - {group_command.description}\n" sub_command_list += f"└> **{group_command.name}** - {file.get(f'_{group_command.parent}_{group_command.name}')}\n"
subcommands = Texts( subcommands = Texts(
'help', self.context 'help', self.context
).get( ).get(
'command_help.subcommands' 'command_help.subcommands'
) )
formatted.add_field(name=subcommands, value=sub_cmd_list, inline=False) formatted.add_field(name=subcommands, value=sub_command_list, inline=False)
await self.context.send(embed=formatted) await self.context.send(embed=formatted)
async def send_command_help(self, command): async def send_command_help(self, command):
@ -193,7 +201,7 @@ class HelpCommand(commands.HelpCommand):
return await self.send_error_message( return await self.send_error_message(
self.command_not_found(command.name)) self.command_not_found(command.name))
formatted = self.common_command_formatting( formatted = self.command_formatting(
discord.Embed(color=discord.Color.blue()), discord.Embed(color=discord.Color.blue()),
command command
) )

View file

@ -243,9 +243,7 @@ class Logs(commands.Cog):
msg = f'{emoji} `[{dt:%Y-%m-%d %H:%M:%S}] {record.message}`' msg = f'{emoji} `[{dt:%Y-%m-%d %H:%M:%S}] {record.message}`'
await self.webhook.send(msg) await self.webhook.send(msg)
@commandExtra(name='commandstats', hidden=True, category='misc', @commandExtra(name='commandstats', hidden=True, category='misc')
description=Texts('logs_help').get('_commandstats'),
help=Texts('logs_help').get('_commandstats__short'))
@commands.is_owner() @commands.is_owner()
async def _commandstats(self, ctx, limit=20): async def _commandstats(self, ctx, limit=20):
counter = self.bot.command_stats counter = self.bot.command_stats
@ -260,9 +258,7 @@ class Logs(commands.Cog):
await ctx.send(f'```\n{output}\n```') await ctx.send(f'```\n{output}\n```')
@commandExtra(name='socketstats', hidden=True, category='misc', @commandExtra(name='socketstats', hidden=True, category='misc')
description=Texts('logs_help').get('_socketstats'),
help=Texts('logs_help').get('_socketstats__short'))
@commands.is_owner() @commands.is_owner()
async def _socketstats(self, ctx): async def _socketstats(self, ctx):
delta = datetime.datetime.utcnow() - self.bot.uptime delta = datetime.datetime.utcnow() - self.bot.uptime
@ -272,9 +268,7 @@ class Logs(commands.Cog):
await ctx.send( await ctx.send(
f'{total} socket events observed ({cpm:.2f}/minute):\n{self.bot.socket_stats}') f'{total} socket events observed ({cpm:.2f}/minute):\n{self.bot.socket_stats}')
@commandExtra(name='uptime', category='misc', @commandExtra(name='uptime', category='misc')
description=Texts('logs_help').get('_uptime'),
help=Texts('logs_help').get('_uptime__short'))
async def _uptime(self, ctx): async def _uptime(self, ctx):
uptime = humanize.naturaltime( uptime = humanize.naturaltime(
datetime.datetime.utcnow() - self.bot.uptime) datetime.datetime.utcnow() - self.bot.uptime)

View file

@ -15,7 +15,7 @@ from utils import groupExtra
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class Polls(commands.Cog): class Poll(commands.Cog):
def __init__(self, bot: TuxBot): def __init__(self, bot: TuxBot):
self.bot = bot self.bot = bot
@ -205,17 +205,12 @@ class Polls(commands.Cog):
poll.content = json.dumps(content) poll.content = json.dumps(content)
self.bot.database.session.commit() self.bot.database.session.commit()
@groupExtra(name='poll', aliases=['sondage'], @groupExtra(name='poll', aliases=['sondage'], category='poll')
category='poll',
description=Texts('poll_help').get('_poll'),
help=Texts('poll_help').get('_poll__short'))
async def _poll(self, ctx: commands.Context): async def _poll(self, ctx: commands.Context):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help('sondage') await ctx.send_help('poll')
@_poll.group(name='create', aliases=['new', 'nouveau'], @_poll.group(name='create', aliases=['new', 'nouveau'])
description=Texts('poll_help').get('_poll_create'),
help=Texts('poll_help').get('_poll_create__short'))
async def _poll_create(self, ctx: commands.Context, *, poll: str): async def _poll_create(self, ctx: commands.Context, *, poll: str):
is_anonymous = '--anonyme' in poll is_anonymous = '--anonyme' in poll
poll = poll.replace('--anonyme', '') poll = poll.replace('--anonyme', '')
@ -224,4 +219,4 @@ class Polls(commands.Cog):
def setup(bot: TuxBot): def setup(bot: TuxBot):
bot.add_cog(Polls(bot)) bot.add_cog(Poll(bot))

View file

@ -81,9 +81,7 @@ class Useful(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='iplocalise', category='network', @commandExtra(name='iplocalise', category='network')
description=Texts('useful_help').get('_iplocalise'),
help=Texts('useful_help').get('_iplocalise__short'))
async def _iplocalise(self, ctx: commands.Context, addr, ip_type=''): async def _iplocalise(self, ctx: commands.Context, addr, ip_type=''):
addr = re.sub(r'http(s?)://', '', addr) addr = re.sub(r'http(s?)://', '', addr)
addr = addr[:-1] if addr.endswith('/') else addr addr = addr[:-1] if addr.endswith('/') else addr
@ -147,9 +145,7 @@ class Useful(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='getheaders', category='network', @commandExtra(name='getheaders', category='network')
description=Texts('useful_help').get('_getheaders'),
help=Texts('useful_help').get('_getheaders__short'))
async def _getheaders(self, ctx: commands.Context, addr: str): async def _getheaders(self, ctx: commands.Context, addr: str):
if (addr.startswith('http') or addr.startswith('ftp')) is not True: if (addr.startswith('http') or addr.startswith('ftp')) is not True:
addr = f"http://{addr}" addr = f"http://{addr}"
@ -179,10 +175,7 @@ class Useful(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='git', aliases=['sources', 'source', 'github'], @commandExtra(name='git', aliases=['sources', 'source', 'github'], category='misc')
category='misc',
description=Texts('useful_help').get('_git'),
help=Texts('useful_help').get('_git__short'))
async def _git(self, ctx): async def _git(self, ctx):
e = discord.Embed( e = discord.Embed(
title=Texts('useful', ctx).get('git repo'), title=Texts('useful', ctx).get('git repo'),
@ -197,9 +190,7 @@ class Useful(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='quote', category='misc', @commandExtra(name='quote', category='misc')
description=Texts('useful_help').get('_quote'),
help=Texts('useful_help').get('_quote__short'))
async def _quote(self, ctx, message_id: discord.Message): async def _quote(self, ctx, message_id: discord.Message):
e = discord.Embed( e = discord.Embed(
colour=message_id.author.colour, colour=message_id.author.colour,
@ -221,9 +212,7 @@ class Useful(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='ping', category='network', @commandExtra(name='ping', category='network')
description=Texts('useful_help').get('_ping'),
help=Texts('useful_help').get('_ping__short'))
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()
@ -241,9 +230,7 @@ class Useful(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='info', aliases=['about'], category='misc', @commandExtra(name='info', aliases=['about'], category='misc')
description=Texts('useful_help').get('_info'),
help=Texts('useful_help').get('_info__short'))
async def _info(self, ctx: commands.Context): async def _info(self, ctx: commands.Context):
proc = psutil.Process() proc = psutil.Process()
total, python = self.fetch_info() total, python = self.fetch_info()
@ -326,10 +313,7 @@ class Useful(commands.Cog):
########################################################################### ###########################################################################
@commandExtra(name='credits', aliases=['contributors', 'authors'], @commandExtra(name='credits', aliases=['contributors', 'authors'], category='misc')
category='misc',
description=Texts('useful_help').get('_credits'),
help=Texts('useful_help').get('_credits__short'))
async def _credits(self, ctx: commands.Context): async def _credits(self, ctx: commands.Context):
e = discord.Embed( e = discord.Embed(
title=Texts('useful', ctx).get('Contributors'), title=Texts('useful', ctx).get('Contributors'),
@ -353,18 +337,12 @@ class Useful(commands.Cog):
await ctx.send(embed=e) await ctx.send(embed=e)
########################################################################### ###########################################################################
@groupExtra(name='cb', aliases=['cc'], @groupExtra(name='cb', aliases=['cc'], category='misc')
category='misc',
description=Texts('useful_help').get('_cb'),
help=Texts('useful_help').get('_cb__short'))
async def _cb(self, ctx: commands.Context): async def _cb(self, ctx: commands.Context):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help('cb') await ctx.send_help('cb')
@_cb.command(name='validate', aliases=['valid', 'correct'], @_cb.command(name='validate', aliases=['valid', 'correct'], category='misc')
category='misc',
description=Texts('useful_help').get('_cb_validate'),
help=Texts('useful_help').get('_cb_validate__short'))
async def _cb_validate(self, ctx: commands.Context, *, number: int): async def _cb_validate(self, ctx: commands.Context, *, number: int):
valid = self.luhn_checker(number) valid = self.luhn_checker(number)
@ -378,10 +356,7 @@ class Useful(commands.Cog):
) )
) )
@_cb.command(name='generate', aliases=['new', 'get'], @_cb.command(name='generate', aliases=['new', 'get'], category='misc')
category='misc',
description=Texts('useful_help').get('_cb_generate'),
help=Texts('useful_help').get('_cb_generate__short'))
async def _cb_generate(self, ctx: commands.Context): async def _cb_generate(self, ctx: commands.Context):
number = random.randint(4000_0000_0000_0000, 5999_9999_9999_9999) number = random.randint(4000_0000_0000_0000, 5999_9999_9999_9999)
while not self.luhn_checker(number): while not self.luhn_checker(number):

View file

@ -19,16 +19,12 @@ class User(commands.Cog):
########################################################################### ###########################################################################
@groupExtra(name='alias', aliases=['aliases'], category='alias', @groupExtra(name='alias', aliases=['aliases'], category='alias')
description=Texts('user_help').get('_alias'),
help=Texts('user_help').get('_alias__short'))
async def _alias(self, ctx: commands.Context): async def _alias(self, ctx: commands.Context):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
await ctx.send_help('alias') await ctx.send_help('alias')
@_alias.command(name='add', aliases=['set', 'new'], @_alias.command(name='add', aliases=['set', 'new'])
description=Texts('user_help').get('_alias_add'),
help=Texts('user_help').get('_alias_add__short'))
async def _alias_add(self, ctx: commands.Context, *, user_alias: str): async def _alias_add(self, ctx: commands.Context, *, user_alias: str):
is_global = False is_global = False
if '--global' in user_alias: if '--global' in user_alias:
@ -55,15 +51,11 @@ class User(commands.Cog):
self.bot.database.session.add(alias) self.bot.database.session.add(alias)
self.bot.database.session.commit() self.bot.database.session.commit()
@_alias.command(name='remove', aliases=['drop', 'del', 'delete'], @_alias.command(name='remove', aliases=['drop', 'del', 'delete'])
description=Texts('user_help').get('_alias_remove'),
help=Texts('user_help').get('_alias_remove__short'))
async def _alias_remove(self, ctx: commands.Context, prefix: str): async def _alias_remove(self, ctx: commands.Context, prefix: str):
... ...
@_alias.command(name='list', aliases=['show', 'all'], @_alias.command(name='list', aliases=['show', 'all'])
description=Texts('user_help').get('_alias_list'),
help=Texts('user_help').get('_alias_list__short'))
async def _alias_list(self, ctx: commands.Context): async def _alias_list(self, ctx: commands.Context):
... ...

28
database.py Normal file
View file

@ -0,0 +1,28 @@
from utils import Config
from utils.models import Base
from utils import Database
from utils.models.lang import LangModel
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--migrate", action="store_true")
parser.add_argument("-s", "--seed", action="store_true")
args = parser.parse_args()
database = Database(Config("./configs/config.cfg"))
if args.migrate:
print("Migrate...")
Base.metadata.create_all(database.engine)
print("Done!")
if args.seed:
print('Seeding...')
default = LangModel(key="default", value="fr")
available = LangModel(key="available", value="fr,en")
database.session.add(default)
database.session.add(available)
database.session.commit()
print("Done!")

View file

@ -1,6 +0,0 @@
from utils import Config
from utils import Database
database = Database(Config("./configs/config.cfg"))
Base.metadata.create_all(database.engine)

View file

@ -5,8 +5,6 @@ class commandsPlus(commands.Command):
def __init__(self, func, **kwargs): def __init__(self, func, **kwargs):
super().__init__(func, **kwargs) super().__init__(func, **kwargs)
self.category = kwargs.get("category", 'other') self.category = kwargs.get("category", 'other')
self.help = kwargs.get("help", 'No Help Provided')
self.usage = kwargs.get("usage", 'No Usage Provided')
def commandExtra(*args, **kwargs): def commandExtra(*args, **kwargs):
@ -17,9 +15,6 @@ class GroupPlus(commands.Group):
def __init__(self, func, **kwargs): def __init__(self, func, **kwargs):
super().__init__(func, **kwargs) super().__init__(func, **kwargs)
self.category = kwargs.get("category", 'other') self.category = kwargs.get("category", 'other')
self.help = kwargs.get("help", 'No Help Provided')
self.usage = kwargs.get("usage", 'No Usage Provided')
def groupExtra(*args, **kwargs): def groupExtra(*args, **kwargs):
return commands.group(*args, **kwargs, cls=GroupPlus) return commands.group(*args, **kwargs, cls=GroupPlus)

View file

@ -16,7 +16,7 @@ msgstr ""
msgid 'main_page.description' msgid 'main_page.description'
msgstr "Made by {}\nWhen using commands, <> means a required argument and [] means an optional argument.\n***(These symbols shouldn't be written)***" msgstr "When using commands, **<>** means a **required argument** and **[]** means an **optional** argument.\n***(Don't type these symbols!)***"
msgid 'main_page.commands' msgid 'main_page.commands'
msgstr 'Commands' msgstr 'Commands'

View file

@ -19,7 +19,7 @@ msgstr ""
########################################################################### ###########################################################################
msgid '_say' msgid '_say'
msgstr 'Permet de faire en sorte que le TuxBot envoi votre message' msgstr 'Permet de faire en sorte que le TuxBot envoie votre message'
msgid '_say__short' msgid '_say__short'
msgstr 'Faire parler TuxBot' msgstr 'Faire parler TuxBot'
@ -161,13 +161,13 @@ msgstr '[sous-commande]'
########################################################################### ###########################################################################
msgid '_warn_new' msgid '_warn_add'
msgstr "Permet d'ajouter un avertissement à un membre en donnant une raison" msgstr "Permet d'ajouter un avertissement à un membre en donnant une raison"
msgid '_warn_new__short' msgid '_warn_add__short'
msgstr 'Ajouter un avertissement a un membre' msgstr 'Ajouter un avertissement a un membre'
msgid '_warn_new__usage' msgid '_warn_add__usage'
msgstr '<ID/Pseudo/Mention du membre> <raison>' msgstr '<ID/Pseudo/Mention du membre> <raison>'
########################################################################### ###########################################################################
@ -257,7 +257,7 @@ msgid '_prefix_list'
msgstr "Permet d'afficher tous les prefixes définis pour ce serveur" msgstr "Permet d'afficher tous les prefixes définis pour ce serveur"
msgid '_prefix_list__short' msgid '_prefix_list__short'
msgstr 'Lister les prefixes pour ce servuer' msgstr 'Lister les prefixes pour ce serveur'
msgid '_prefix_list__usage' msgid '_prefix_list__usage'
msgstr '' msgstr ''

View file

@ -16,7 +16,7 @@ msgstr ""
msgid 'main_page.description' msgid 'main_page.description'
msgstr "Créé par {}\nLorsque vous utilisez les commandes, <> correspond à un argument obligatoire et [] à un argument optionnel.\n***(Vous ne devez pas écrire ces symboles)***" msgstr "Lorsque vous utilisez les commandes, **<>** correspond à un argument **obligatoire** et **[]** à un argument **optionnel**.\n***(N'écrivez pas ces symboles!)***"
msgid 'main_page.commands' msgid 'main_page.commands'
msgstr 'Commandes' msgstr 'Commandes'

View file

@ -16,4 +16,4 @@ msgstr ""
msgid "_uptime__short" msgid "_uptime__short"
msgstr "Retourne depuis quand le bot est en ligne." msgstr "Retourne depuis quand TuxBot est en ligne."

View file

@ -15,3 +15,26 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
###########################################################################
########################## POLLS #####################################
###########################################################################
msgid '_poll'
msgstr "Affiche l'aide relative a la commande `sondage`"
msgid '_poll__short'
msgstr "Afficher l'aide pour `sondage`"
msgid '_poll__usage'
msgstr '[sous-commande]'
###########################################################################
msgid '_poll_create'
msgstr "Créez un sondage basé sur les réactions ! *(**BETA!** ajoutez `--anonyme` pour rendre les réponses anonymes)*"
msgid '_poll_create__short'
msgstr 'Créer un sondage'
msgid '_poll_create__usage'
msgstr '<question> | <réponse A> | <réponse B> | [réponse C] | [réponse D] | [...]'

View file

@ -37,7 +37,7 @@ deactivate () {
# unset irrelevant variables # unset irrelevant variables
deactivate nondestructive deactivate nondestructive
VIRTUAL_ENV="/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv" VIRTUAL_ENV="/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv"
export VIRTUAL_ENV export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH" _OLD_VIRTUAL_PATH="$PATH"

View file

@ -8,7 +8,7 @@ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PA
# Unset irrelevant variables. # Unset irrelevant variables.
deactivate nondestructive deactivate nondestructive
setenv VIRTUAL_ENV "/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv" setenv VIRTUAL_ENV "/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv"
set _OLD_VIRTUAL_PATH="$PATH" set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH" setenv PATH "$VIRTUAL_ENV/bin:$PATH"

View file

@ -29,7 +29,7 @@ end
# unset irrelevant variables # unset irrelevant variables
deactivate nondestructive deactivate nondestructive
set -gx VIRTUAL_ENV "/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv" set -gx VIRTUAL_ENV "/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv"
set -gx _OLD_VIRTUAL_PATH $PATH set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH set -gx PATH "$VIRTUAL_ENV/bin" $PATH

View file

@ -1,8 +1,10 @@
#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python #!/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import sys import sys
from chardet.cli.chardetect import main from chardet.cli.chardetect import main
if __name__ == '__main__': if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main()) sys.exit(main())

View file

@ -1,4 +1,4 @@
#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python #!/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import sys import sys

View file

@ -1,8 +1,10 @@
#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python #!/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import sys import sys
from import_expression.__main__ import main from import_expression.__main__ import main
if __name__ == '__main__': if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main()) sys.exit(main())

View file

@ -1,4 +1,4 @@
#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python #!/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import sys import sys

View file

@ -1,4 +1,4 @@
#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python #!/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import sys import sys

View file

@ -1,8 +1,10 @@
#!/home/romain/gnousEU/rm-dev01/tuxbot-bot/venv/bin/python #!/home/romain/jetbrains/IDEs/PycharmProjects/gnousEU/discord/tuxbot-bot/venv/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import sys import sys
from tcp_latency.tcp_latency import _main from tcp_latency.tcp_latency import _main
if __name__ == '__main__': if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(_main()) sys.exit(_main())