diff --git a/README.md b/README.md index dee359e..0be4848 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ - [ ] Send email or Telegram's message when something is wrong on the bot - [ ] Create skynet (group of multiple commands about sky (planes, meteo,...)) - - --- + + ------- # Cogs.admin commands @@ -45,4 +45,12 @@ - [x] delete - [x] deletefrom `removed`, now `delete (from|to|in)` - [x] embed `removed`, cause : `never used` + + --- + + # Cogs.basics commands + - [x] ping + - [x] info + - [ ] help + - [ ] credits `new command` \ No newline at end of file diff --git a/bot.py b/bot.py index b5fb74d..adc6fdc 100755 --- a/bot.py +++ b/bot.py @@ -23,6 +23,7 @@ log = logging.getLogger(__name__) l_extensions = ( 'cogs.admin', + 'cogs.basics', 'jishaku', ) diff --git a/cogs/basics.py b/cogs/basics.py new file mode 100644 index 0000000..2d56eea --- /dev/null +++ b/cogs/basics.py @@ -0,0 +1,88 @@ +import platform +import time + +import discord +import humanize +import psutil +from discord.ext import commands + +from bot import TuxBot +from .utils.lang import Texts + + +class Basics(commands.Cog): + + def __init__(self, bot: TuxBot): + self.bot = bot + + """---------------------------------------------------------------------""" + + @commands.command(name='ping') + async def _ping(self, ctx: commands.Context): + start = time.perf_counter() + await ctx.trigger_typing() + end = time.perf_counter() + + latency = round(self.bot.latency * 1000, 2) + typing = round((end - start) * 1000, 2) + + e = discord.Embed(title='Ping', color=discord.Color.teal()) + e.add_field(name='Websocket', value=f'{latency}ms') + e.add_field(name='Typing', value=f'{typing}ms') + await ctx.send(embed=e) + + """---------------------------------------------------------------------""" + + @commands.command(name='info') + async def _info(self, ctx: commands.Context): + proc = psutil.Process() + with proc.oneshot(): + mem = proc.memory_full_info() + e = discord.Embed( + title=f"{Texts('basics').get('Information about TuxBot')}", + color=0x89C4F9) + e.add_field( + name=f"__:busts_in_silhouette: " + f"{Texts('basics').get('Development')}__", + value=f"**Romain#5117:** [git](https://git.gnous.eu/Romain)\n" + f"**Outout#4039:** [git](https://git.gnous.eu/mael)\n", + inline=True + ) + e.add_field( + name="__<:python:596577462335307777> Python__", + value=f"**python** `{platform.python_version()}`\n" + f"**discord.py** `{discord.__version__}`", + inline=True + ) + e.add_field( + name="__:gear: Usage__", + value=f"**{humanize.naturalsize(mem.rss)}** " + f"{Texts('basics').get('physical memory')}\n" + f"**{humanize.naturalsize(mem.vms)}** " + f"{Texts('basics').get('virtual memory')}\n", + inline=True + ) + + e.add_field( + name=f"__{Texts('basics').get('Servers count')}__", + value=str(len(self.bot.guilds)), + inline=True + ) + e.add_field( + name=f"__{Texts('basics').get('Channels count')}__", + value=str(len([_ for _ in self.bot.get_all_channels()])), + inline=True + ) + e.add_field( + name=f"__{Texts('basics').get('Members count')}__", + value=str(len([_ for _ in self.bot.get_all_members()])), + inline=True + ) + + e.set_footer(text=f'version: {self.bot.version}') + + await ctx.send(embed=e) + + +def setup(bot: TuxBot): + bot.add_cog(Basics(bot)) diff --git a/cogs/utils/version.py b/cogs/utils/version.py index 37f922c..9aaf3ec 100644 --- a/cogs/utils/version.py +++ b/cogs/utils/version.py @@ -9,4 +9,4 @@ class Version: def __str__(self) -> str: build = self.build[:10] - return f'v{self.major}.{self.minor}.{self.patch}{self.pre_release}-{build}' + return f'v{self.major}.{self.minor}.{self.patch}{self.pre_release}+{build}' diff --git a/launcher.py b/launcher.py index b425a74..8712926 100644 --- a/launcher.py +++ b/launcher.py @@ -5,7 +5,6 @@ import socket import sys import click -import git import requests from bot import TuxBot diff --git a/locales/en/LC_MESSAGES/basics.mo b/locales/en/LC_MESSAGES/basics.mo new file mode 100644 index 0000000..e56e9c9 Binary files /dev/null and b/locales/en/LC_MESSAGES/basics.mo differ diff --git a/locales/en/LC_MESSAGES/basics.po b/locales/en/LC_MESSAGES/basics.po new file mode 100644 index 0000000..ebf8a66 --- /dev/null +++ b/locales/en/LC_MESSAGES/basics.po @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2019-09-08 19:04+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" + + +msgid "Information about TuxBot" +msgstr "" + +msgid "Development" +msgstr "" + +msgid "physical memory" +msgstr "" + +msgid "virtual memory" +msgstr "" + +msgid "Servers count" +msgstr "" + +msgid "Channels count" +msgstr "" + +msgid "Members count" +msgstr "" \ No newline at end of file diff --git a/locales/fr/LC_MESSAGES/basics.mo b/locales/fr/LC_MESSAGES/basics.mo new file mode 100644 index 0000000..8a09184 Binary files /dev/null and b/locales/fr/LC_MESSAGES/basics.mo differ diff --git a/locales/fr/LC_MESSAGES/basics.po b/locales/fr/LC_MESSAGES/basics.po new file mode 100644 index 0000000..fd644d0 --- /dev/null +++ b/locales/fr/LC_MESSAGES/basics.po @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2019-09-08 19:04+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" + + +msgid "Information about TuxBot" +msgstr "Informations sur TuxBot" + +msgid "Development" +msgstr "Développement" + +msgid "physical memory" +msgstr "mémoire physique" + +msgid "virtual memory" +msgstr "mémoire virtuelle" + +msgid "Servers count" +msgstr "Nombre de serveurs" + +msgid "Channels count" +msgstr "Nombre de channel" + +msgid "Members count" +msgstr "Nombre de membres" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index eff90f1..789361e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,9 @@ +humanize discord.py[voice] jishaku lxml click asyncpg>=0.12.0 -gitpython \ No newline at end of file +gitpython +requests +psutil \ No newline at end of file