From b829d23881ad884482630c09d91a3eb0da4f2a93 Mon Sep 17 00:00:00 2001 From: TheRandomFurryGuy Date: Tue, 4 Apr 2023 22:02:00 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/bot.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/source/bot.py b/source/bot.py index 8326b9b..4ee278a 100644 --- a/source/bot.py +++ b/source/bot.py @@ -2,8 +2,13 @@ from os import environ # для получения переменных окру import discord from discord.ext import commands # поддержка красивых команд import gitlab # прикол +import csv # база данных +from os import remove +database = open("database.csv", "w") +database.close() +slovar = dict() gl = gitlab.Gitlab(url = 'https://gitlab.megu.one', @@ -32,6 +37,17 @@ async def on_message(message): if project.issues.create({'title': issue_text,'description': 'Something useful here.'}): await message.channel.send("Задача «" + issue_text + "» создана.") + #if message.content.startswith('/project'): + #slovar.update({message.channel.id: message.content.replace("/project ","")}) + #await message.channel.send(slovar) + + if message.content.startswith('/project'): + database = open("database.csv", "a+") + database.write(str({message.channel.id: message.content.replace("/project ","")}) + "\n") + database.close() + + if message.content.startswith('/remove'): + remove("database.csv") #command_issue_extras = dict() #@tree_commands.command(name="issue", description="создать задачу на GitLab", nsfw=False, auto_locale_strings=False) @@ -42,11 +58,4 @@ async def on_message(message): #asyncio.run(sync(*command_issue, guild=None)) - - - - - - - discord_bot.run(environ.get("TOKEN_DISCORD")) \ No newline at end of file