From 571754086a38a10407eaeab032f19014d3e1c7cd Mon Sep 17 00:00:00 2001 From: attilavs2 Date: Thu, 22 Feb 2024 19:43:30 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20!pinguncon=20et=20d=C3=A9buts=20autres?= =?UTF-8?q?=20trucs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- db.py | 5 +++++ ecoplus.py | 29 +++++++++++++++++++++++------ start.sh | 1 + 4 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 db.py create mode 100644 start.sh diff --git a/.gitignore b/.gitignore index c1d5865..c551ebf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -start.sh +secrets.txt # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/db.py b/db.py new file mode 100644 index 0000000..5a67c1e --- /dev/null +++ b/db.py @@ -0,0 +1,5 @@ +import psycopg + +#filled in at runtime +credentials = "" + diff --git a/ecoplus.py b/ecoplus.py index be49c51..2934a8f 100644 --- a/ecoplus.py +++ b/ecoplus.py @@ -1,6 +1,18 @@ import sys import discord +import db + +secrets_file = open(sys.argv[1], mode="rt") + +secrets = secrets_file.read() + +secrets = secrets.split(";") + +token = secrets[0] + +db.credentials = secrets[1] + intents = discord.Intents.default() intents.message_content = True @@ -8,14 +20,19 @@ client = discord.Client(intents=intents) @client.event async def on_ready(): - print(f'We have logged in as {client.user}') + print(f'We have logged in as {client.user}') @client.event async def on_message(message): - if message.author == client.user: - return + if message.author == client.user: + return - if message.content.startswith('$hello'): - await message.channel.send('Hello!') + content = message.content -client.run(str(sys.argv[1])) + if content == "!hello": + await message.channel.send('henlo') + return + if content == "!pinguncon": + await message.channel.send("<499533339468759052>") + +client.run(token) diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..4873386 --- /dev/null +++ b/start.sh @@ -0,0 +1 @@ +python3 ecoplus.py secrets.txt