feat(commands|Utils>info): feat cpu usage

This commit is contained in:
Romain J 2021-01-25 14:52:30 +01:00
parent 1fb3e035bd
commit fa3069244d
11 changed files with 97 additions and 93 deletions

View file

@ -13,7 +13,7 @@ platforms = linux
[options]
packages = find_namespace:
python_requires = >=3.7
python_requires = >=3.8
install_requires =
appdirs>=1.4.4
asyncpg>=0.21.0

View file

@ -1,5 +1,5 @@
from setuptools import setup
setup(
python_requires=">=3.7",
python_requires=">=3.8",
)

View file

@ -68,14 +68,12 @@ class Admin(commands.Cog, name="Admin"):
# =========================================================================
@command_extra(name="quit", aliases=["shutdown"], deletable=False)
@commands.guild_only()
@checks.is_owner()
async def _quit(self, ctx: ContextPlus):
await ctx.send("*quit...*")
await self.bot.shutdown()
@command_extra(name="restart", deletable=False)
@commands.guild_only()
@checks.is_owner()
async def _restart(self, ctx: ContextPlus):
await ctx.send("*restart...*")

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Tuxbot-bot\n"
"Report-Msgid-Bugs-To: rick@gnous.eu\n"
"POT-Creation-Date: 2021-01-22 10:16+0100\n"
"POT-Creation-Date: 2021-01-25 14:36+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Tuxbot-bot\n"
"Report-Msgid-Bugs-To: rick@gnous.eu\n"
"POT-Creation-Date: 2021-01-22 10:16+0100\n"
"POT-Creation-Date: 2021-01-25 14:36+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View file

@ -67,7 +67,8 @@ async def _suggest_reaction_add(
content["fields"].append(
{
"name": f"__{emote} - {upper_first(suggest.proposition)}__",
"name": f"__{emote} "
f"- {upper_first(suggest.proposition)}__",
"value": "**0** vote",
}
)

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Tuxbot-bot\n"
"Report-Msgid-Bugs-To: rick@gnous.eu\n"
"POT-Creation-Date: 2021-01-22 10:16+0100\n"
"POT-Creation-Date: 2021-01-25 14:36+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View file

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Tuxbot-bot\n"
"Report-Msgid-Bugs-To: rick@gnous.eu\n"
"POT-Creation-Date: 2020-11-11 02:44+0100\n"
"POT-Creation-Date: 2021-01-25 14:36+0100\n"
"PO-Revision-Date: 2020-06-10 00:38+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
@ -17,104 +17,104 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: tuxbot/cogs/Utils/utils.py:38
#: tuxbot/cogs/Utils/utils.py:40
msgid "Information about TuxBot"
msgstr ""
msgstr "Information sur TuxBot"
#: tuxbot/cogs/Utils/utils.py:44
#: tuxbot/cogs/Utils/utils.py:46
msgid "__:busts_in_silhouette: Development__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:61
#: tuxbot/cogs/Utils/utils.py:63
msgid ""
"**{}** physical memory\n"
"**{}** virtual memory"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:72
msgid "__Servers count__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:77
msgid "__Servers count__"
msgstr "__Nombre de serveurs__"
#: tuxbot/cogs/Utils/utils.py:82
msgid "__Channels count__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:82
#: tuxbot/cogs/Utils/utils.py:87
msgid "__Members count__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:88
#: tuxbot/cogs/Utils/utils.py:93
msgid "__:file_folder: Files__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:95
#: tuxbot/cogs/Utils/utils.py:100
msgid "__¶ Lines__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:98
#: tuxbot/cogs/Utils/utils.py:103
msgid "class"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:100
#: tuxbot/cogs/Utils/utils.py:106
msgid "functions"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:102
#: tuxbot/cogs/Utils/utils.py:109
msgid "coroutines"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:104
#: tuxbot/cogs/Utils/utils.py:112
msgid "comments"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:105
#: tuxbot/cogs/Utils/utils.py:118
msgid "__Latest changes__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:111
#: tuxbot/cogs/Utils/utils.py:124
msgid "__:link: Links__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:116
#: tuxbot/cogs/Utils/utils.py:129
msgid "| [Invite]"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:131
#: tuxbot/cogs/Utils/utils.py:144
msgid "Contributors"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:187
#: tuxbot/cogs/Utils/utils.py:200
msgid "Invite"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:191
#: tuxbot/cogs/Utils/utils.py:204
msgid "Minimal"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:193
#: tuxbot/cogs/Utils/utils.py:206
msgid ""
"The minimum permissions include the strict requirements for the proper "
"functioning of all basics commands.\n"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:198 tuxbot/cogs/Utils/utils.py:210
#: tuxbot/cogs/Utils/utils.py:211 tuxbot/cogs/Utils/utils.py:223
msgid "[Add!]"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:203
#: tuxbot/cogs/Utils/utils.py:216
msgid "Admin"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:205
#: tuxbot/cogs/Utils/utils.py:218
msgid ""
"All minimal permissions + extra permissions for admin commands such as kick "
"and ban\n"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:233
#: tuxbot/cogs/Utils/utils.py:246
msgid "Unable to find `{}`"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:241
#: tuxbot/cogs/Utils/utils.py:254
msgid "Unable to fetch lines for `{}`"
msgstr ""

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Tuxbot-bot\n"
"Report-Msgid-Bugs-To: rick@gnous.eu\n"
"POT-Creation-Date: 2020-11-11 02:44+0100\n"
"POT-Creation-Date: 2021-01-25 14:36+0100\n"
"PO-Revision-Date: 2020-06-10 00:38+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
@ -18,83 +18,82 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: tuxbot/cogs/Utils/utils.py:38
#: tuxbot/cogs/Utils/utils.py:40
msgid "Information about TuxBot"
msgstr "Information sur TuxBot"
#: tuxbot/cogs/Utils/utils.py:44
#: tuxbot/cogs/Utils/utils.py:46
msgid "__:busts_in_silhouette: Development__"
msgstr "__:busts_in_silhouette: Développement__"
#: tuxbot/cogs/Utils/utils.py:61
#: tuxbot/cogs/Utils/utils.py:63
msgid ""
"**{}** physical memory\n"
"**{}** virtual memory"
"**{}** virtual memory\n"
"**{}**% CPU"
msgstr ""
"**{}** mémoire physique\n"
"**{}** mémoire virtuelle"
#: tuxbot/cogs/Utils/utils.py:72
#: tuxbot/cogs/Utils/utils.py:77
msgid "__Servers count__"
msgstr "__Nombre de serveurs__"
#: tuxbot/cogs/Utils/utils.py:77
#: tuxbot/cogs/Utils/utils.py:82
msgid "__Channels count__"
msgstr "__Nombre de salons__"
#: tuxbot/cogs/Utils/utils.py:82
#: tuxbot/cogs/Utils/utils.py:87
msgid "__Members count__"
msgstr "__Nombre de membres__"
#: tuxbot/cogs/Utils/utils.py:88
#: tuxbot/cogs/Utils/utils.py:93
msgid "__:file_folder: Files__"
msgstr "__:file_folder: Fichiers__"
#: tuxbot/cogs/Utils/utils.py:95
#: tuxbot/cogs/Utils/utils.py:100
msgid "__¶ Lines__"
msgstr "__¶ Lines__"
#: tuxbot/cogs/Utils/utils.py:98
#: tuxbot/cogs/Utils/utils.py:103
msgid "class"
msgstr "classes"
#: tuxbot/cogs/Utils/utils.py:100
#: tuxbot/cogs/Utils/utils.py:106
msgid "functions"
msgstr "fonctions"
#: tuxbot/cogs/Utils/utils.py:102
#: tuxbot/cogs/Utils/utils.py:109
msgid "coroutines"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:104
#: tuxbot/cogs/Utils/utils.py:112
msgid "comments"
msgstr "commentaires"
#: tuxbot/cogs/Utils/utils.py:105
#: tuxbot/cogs/Utils/utils.py:118
msgid "__Latest changes__"
msgstr "__Derniers changements__"
#: tuxbot/cogs/Utils/utils.py:111
#: tuxbot/cogs/Utils/utils.py:124
msgid "__:link: Links__"
msgstr "__:link: Liens__"
#: tuxbot/cogs/Utils/utils.py:116
#: tuxbot/cogs/Utils/utils.py:129
msgid "| [Invite]"
msgstr "| [Invitation]"
#: tuxbot/cogs/Utils/utils.py:131
#: tuxbot/cogs/Utils/utils.py:144
msgid "Contributors"
msgstr "Contributeurs"
#: tuxbot/cogs/Utils/utils.py:187
#: tuxbot/cogs/Utils/utils.py:200
msgid "Invite"
msgstr "Invitation"
#: tuxbot/cogs/Utils/utils.py:191
#: tuxbot/cogs/Utils/utils.py:204
msgid "Minimal"
msgstr "Minimale"
#: tuxbot/cogs/Utils/utils.py:193
#: tuxbot/cogs/Utils/utils.py:206
msgid ""
"The minimum permissions include the strict requirements for the proper "
"functioning of all basics commands.\n"
@ -102,15 +101,15 @@ msgstr ""
"Les permissions minimales avec le strict nécessaire pour le bon "
"fonctionnement des commandes de base\n"
#: tuxbot/cogs/Utils/utils.py:198 tuxbot/cogs/Utils/utils.py:210
#: tuxbot/cogs/Utils/utils.py:211 tuxbot/cogs/Utils/utils.py:223
msgid "[Add!]"
msgstr "[Ajouter !]"
#: tuxbot/cogs/Utils/utils.py:203
#: tuxbot/cogs/Utils/utils.py:216
msgid "Admin"
msgstr "Admin"
#: tuxbot/cogs/Utils/utils.py:205
#: tuxbot/cogs/Utils/utils.py:218
msgid ""
"All minimal permissions + extra permissions for admin commands such as kick "
"and ban\n"
@ -118,10 +117,10 @@ msgstr ""
"Toutes les permissions minimales + les permissions extra pour les commandes "
"d'administration telles que kick et ban\n"
#: tuxbot/cogs/Utils/utils.py:233
#: tuxbot/cogs/Utils/utils.py:246
msgid "Unable to find `{}`"
msgstr "Impossible de trouver `{}`"
#: tuxbot/cogs/Utils/utils.py:241
#: tuxbot/cogs/Utils/utils.py:254
msgid "Unable to fetch lines for `{}`"
msgstr "Impossible de récuperer les lignes pour `{}`"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Tuxbot-bot\n"
"Report-Msgid-Bugs-To: rick@gnous.eu\n"
"POT-Creation-Date: 2021-01-22 10:16+0100\n"
"POT-Creation-Date: 2021-01-25 14:36+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,100 +17,101 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: tuxbot/cogs/Utils/utils.py:38
#: tuxbot/cogs/Utils/utils.py:40
msgid "Information about TuxBot"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:44
#: tuxbot/cogs/Utils/utils.py:46
msgid "__:busts_in_silhouette: Development__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:61
#: tuxbot/cogs/Utils/utils.py:63
msgid ""
"**{}** physical memory\n"
"**{}** virtual memory"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:72
msgid "__Servers count__"
"**{}** virtual memory\n"
"**{}**% CPU"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:77
msgid "__Channels count__"
msgid "__Servers count__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:82
msgid "__Channels count__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:87
msgid "__Members count__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:88
#: tuxbot/cogs/Utils/utils.py:93
msgid "__:file_folder: Files__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:95
#: tuxbot/cogs/Utils/utils.py:100
msgid "__¶ Lines__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:98
#: tuxbot/cogs/Utils/utils.py:103
msgid "class"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:101
#: tuxbot/cogs/Utils/utils.py:106
msgid "functions"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:104
#: tuxbot/cogs/Utils/utils.py:109
msgid "coroutines"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:107
#: tuxbot/cogs/Utils/utils.py:112
msgid "comments"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:113
#: tuxbot/cogs/Utils/utils.py:118
msgid "__Latest changes__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:119
#: tuxbot/cogs/Utils/utils.py:124
msgid "__:link: Links__"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:124
#: tuxbot/cogs/Utils/utils.py:129
msgid "| [Invite]"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:139
#: tuxbot/cogs/Utils/utils.py:144
msgid "Contributors"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:195
#: tuxbot/cogs/Utils/utils.py:200
msgid "Invite"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:199
#: tuxbot/cogs/Utils/utils.py:204
msgid "Minimal"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:201
#: tuxbot/cogs/Utils/utils.py:206
msgid "The minimum permissions include the strict requirements for the proper functioning of all basics commands.\n"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:206 tuxbot/cogs/Utils/utils.py:218
#: tuxbot/cogs/Utils/utils.py:211 tuxbot/cogs/Utils/utils.py:223
msgid "[Add!]"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:211
#: tuxbot/cogs/Utils/utils.py:216
msgid "Admin"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:213
#: tuxbot/cogs/Utils/utils.py:218
msgid "All minimal permissions + extra permissions for admin commands such as kick and ban\n"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:241
#: tuxbot/cogs/Utils/utils.py:246
msgid "Unable to find `{}`"
msgstr ""
#: tuxbot/cogs/Utils/utils.py:249
#: tuxbot/cogs/Utils/utils.py:254
msgid "Unable to fetch lines for `{}`"
msgstr ""

View file

@ -34,6 +34,8 @@ class Utils(commands.Cog, name="Utils"):
with proc.oneshot():
mem = proc.memory_full_info()
cpu = proc.cpu_percent() / psutil.cpu_count()
e = discord.Embed(
title=_("Information about TuxBot", ctx, self.bot.config),
color=0x89C4F9,
@ -58,12 +60,15 @@ class Utils(commands.Cog, name="Utils"):
e.add_field(
name="__:gear: Usage__",
value=_(
"**{}** physical memory\n**{}** virtual memory",
"**{}** physical memory\n"
"**{}** virtual memory\n"
"**{:.2f}**% CPU",
ctx,
self.bot.config,
).format(
humanize.naturalsize(mem.rss),
humanize.naturalsize(mem.vms),
cpu,
),
inline=True,
)