Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
083d14e056 | |||
daed469994 | |||
68ca0cb2fc | |||
4d479f6516 | |||
|
afe76d00c1 | ||
fc06756363 | |||
425ff79c8d | |||
57ea780f2c | |||
78026ee88e |
8 changed files with 85 additions and 10 deletions
28
.github/issue_template.md
vendored
Normal file
28
.github/issue_template.md
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Launch bot
|
||||||
|
3. Type command '...'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS: [e.g. Debian]
|
||||||
|
- Python Version [e.g. 3.7.4]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
|
@ -6,7 +6,7 @@ Ici ce trouve le code source du bot provenant du serveur Discord [Aide GNU/Linu
|
||||||
Il vous faut :
|
Il vous faut :
|
||||||
|
|
||||||
- Un ordinateur sous **GNU/Linux** avec une connexion à internet;
|
- Un ordinateur sous **GNU/Linux** avec une connexion à internet;
|
||||||
- Python3.5 ou + ;
|
- Python3.7 ou + ;
|
||||||
- Installer ``requirements.txt`` (avec ``pip install -r requirements.txt`` par ex)
|
- Installer ``requirements.txt`` (avec ``pip install -r requirements.txt`` par ex)
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
5
bot.py
5
bot.py
|
@ -38,6 +38,8 @@ l_extensions = (
|
||||||
'cogs.utility',
|
'cogs.utility',
|
||||||
'cogs.vocal',
|
'cogs.vocal',
|
||||||
'cogs.private',
|
'cogs.private',
|
||||||
|
'cogs.monitoring',
|
||||||
|
'jishaku'
|
||||||
)
|
)
|
||||||
|
|
||||||
help_attrs = dict(hidden=True, in_help=True, name="DONOTUSE")
|
help_attrs = dict(hidden=True, in_help=True, name="DONOTUSE")
|
||||||
|
@ -68,6 +70,9 @@ class TuxBot(commands.Bot):
|
||||||
f"Impossible de charger l'extension {extension}\n"
|
f"Impossible de charger l'extension {extension}\n"
|
||||||
f"{type(e).__name__}: {e}{colors.ENDC}", file=sys.stderr)
|
f"{type(e).__name__}: {e}{colors.ENDC}", file=sys.stderr)
|
||||||
|
|
||||||
|
async def is_owner(self, user: discord.User):
|
||||||
|
return str(user.id) in config.authorized_id
|
||||||
|
|
||||||
async def on_command_error(self, ctx, error):
|
async def on_command_error(self, ctx, error):
|
||||||
if isinstance(error, commands.NoPrivateMessage):
|
if isinstance(error, commands.NoPrivateMessage):
|
||||||
await ctx.author.send('Cette commande ne peut pas être utilisee '
|
await ctx.author.send('Cette commande ne peut pas être utilisee '
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Basics(commands.Cog):
|
||||||
ping_res = str(subprocess.Popen(["/bin/ping", "-c1", "discordapp.com"],
|
ping_res = str(subprocess.Popen(["/bin/ping", "-c1", "discordapp.com"],
|
||||||
stdout=subprocess.PIPE).stdout.read())
|
stdout=subprocess.PIPE).stdout.read())
|
||||||
formated_res = [item for item in ping_res.split() if 'time=' in item]
|
formated_res = [item for item in ping_res.split() if 'time=' in item]
|
||||||
result = str(formated_res[0])[5:]
|
result = self.bot.latency * 1000 # str(formated_res[0])[5:]
|
||||||
|
|
||||||
if float(result) >= 200:
|
if float(result) >= 200:
|
||||||
em = discord.Embed(title="Ping : " + str(result) + "ms",
|
em = discord.Embed(title="Ping : " + str(result) + "ms",
|
||||||
|
@ -58,13 +58,13 @@ class Basics(commands.Cog):
|
||||||
"""---------------------------------------------------------------------"""
|
"""---------------------------------------------------------------------"""
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def help(self, ctx):
|
async def help(self, ctx, page: int = 1):
|
||||||
"""Affiches l'aide du bot"""
|
"""Affiches l'aide du bot"""
|
||||||
|
page = int(page) if 0 < int(page) < 5 else 1
|
||||||
text = open('texts/help.md').read().split("[split]")
|
text = open('texts/help.md').read().split("[split]")
|
||||||
for txt in text:
|
em = discord.Embed(title='Commandes de TuxBot', description=text[page - 1],
|
||||||
em = discord.Embed(title='Commandes de TuxBot', description=txt,
|
|
||||||
colour=0x89C4F9)
|
colour=0x89C4F9)
|
||||||
await ctx.send(embed=em)
|
await ctx.send(content=f"page {page}/{len(text)}", embed=em)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
|
@ -85,10 +85,10 @@ class Identity(commands.Cog):
|
||||||
embed.set_thumbnail(url = result[2])
|
embed.set_thumbnail(url = result[2])
|
||||||
embed.add_field(name="Nom :", value=result[1], inline=True)
|
embed.add_field(name="Nom :", value=result[1], inline=True)
|
||||||
embed.add_field(name="Système d'exploitation :", value=isexist(result[6]), inline=True)
|
embed.add_field(name="Système d'exploitation :", value=isexist(result[6]), inline=True)
|
||||||
embed.add_field(name="Configuration Système : ", value=isexist(result[7]), inline=True)
|
embed.add_field(name="Configuration Système : ", value=isexist(result[7]), inline=False)
|
||||||
embed.add_field(name="Date de naissance sur discord : ", value=formated_user_birth, inline=True)
|
embed.add_field(name="Date de naissance sur discord : ", value=formated_user_birth, inline=True)
|
||||||
embed.add_field(name="Pays : ", value=isexist(result[8]), inline=True)
|
embed.add_field(name="Pays : ", value=isexist(result[8]), inline=True)
|
||||||
embed.add_field(name="Profil sur le web : ", value=f"https://tuxbot.gnous.eu/users/{result[9]}", inline=True)
|
embed.add_field(name="Profil sur le web : ", value="*indisponible*") # value=f"https://tuxbot.gnous.eu/users/{result[9]}", inline=True)
|
||||||
embed.set_footer(text=f"Enregistré dans le bureau {result[5]} le {formated_cidate}.")
|
embed.set_footer(text=f"Enregistré dans le bureau {result[5]} le {formated_cidate}.")
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
41
cogs/monitoring.py
Normal file
41
cogs/monitoring.py
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import asyncio
|
||||||
|
import threading
|
||||||
|
from aiohttp import web
|
||||||
|
|
||||||
|
from discord.ext import commands
|
||||||
|
from bot import TuxBot
|
||||||
|
|
||||||
|
|
||||||
|
class Monitoring(commands.Cog):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.app = web.Application()
|
||||||
|
|
||||||
|
t = threading.Thread(
|
||||||
|
target=self.run_server,
|
||||||
|
args=(self.aiohttp_server(),)
|
||||||
|
)
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
def aiohttp_server(self):
|
||||||
|
async def hi(request):
|
||||||
|
return web.Response(text="I'm alive !")
|
||||||
|
|
||||||
|
self.app.add_routes([web.get('/', hi)])
|
||||||
|
runner = web.AppRunner(self.app)
|
||||||
|
|
||||||
|
return runner
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def run_server(runner):
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
asyncio.set_event_loop(loop)
|
||||||
|
loop.run_until_complete(runner.setup())
|
||||||
|
site = web.TCPSite(runner, '0.0.0.0', 3389)
|
||||||
|
loop.run_until_complete(site.start())
|
||||||
|
loop.run_forever()
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot: TuxBot):
|
||||||
|
bot.add_cog(Monitoring())
|
||||||
|
|
|
@ -85,6 +85,7 @@ class Sondage(commands.Cog):
|
||||||
end_msg += "\n\"{}\" est le gagnant!".format(top_result)
|
end_msg += "\n\"{}\" est le gagnant!".format(top_result)
|
||||||
await ctx.send(end_msg)
|
await ctx.send(end_msg)
|
||||||
else:
|
else:
|
||||||
|
await ctx.send("please use `@tuxbot poll` (this is rewrite version in beta")
|
||||||
await ctx.message.delete()
|
await ctx.message.delete()
|
||||||
|
|
||||||
text = open('texts/rpoll.md').read()
|
text = open('texts/rpoll.md').read()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
pymysql
|
pymysql
|
||||||
|
gtts
|
||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
lxml==4.2.4
|
lxml==4.2.4
|
||||||
bs4
|
bs4
|
||||||
|
@ -6,4 +7,3 @@ pytz
|
||||||
requests
|
requests
|
||||||
wikipedia
|
wikipedia
|
||||||
pillow
|
pillow
|
||||||
gtts
|
|
Loading…
Reference in a new issue