From 6b4063135c2ebfe73921cc8a7523196814a79f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=97=D0=B0=D0=B6=D0=B8=D0=B3=D0=B8=D0=BD=20=D0=91=D0=BE?= =?UTF-8?q?=D0=B3=D0=B4=D0=B0=D0=BD=20=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5?= =?UTF-8?q?=D0=B5=D0=B2=D0=B8=D1=87?= Date: Mon, 3 Apr 2023 21:47:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D0=B8=D0=B7=20=D0=BE=D0=BA=D1=80=D1=83=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/bot.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/source/bot.py b/source/bot.py index 1143ee0..288a75b 100644 --- a/source/bot.py +++ b/source/bot.py @@ -1,24 +1,35 @@ +from os import environ # для получения переменных окружения import discord +from discord.ext import commands # поддержка красивых команд import gitlab -gl = gitlab.Gitlab(url='https://gitlab.megu.one', private_token='glpat-FsbtfebnSiw1SJ8foYpu') + + + +gl = gitlab.Gitlab(url = 'https://gitlab.megu.one', + private_token = environ.get("TOKEN_GITLAB")) project = gl.projects.get(13) -print(type(gl.issues.list())) + intents = discord.Intents.default() intents.message_content = True -client = discord.Client(intents=intents) +discord_bot = discord.Client(intents=intents) -@client.event + + + +@discord_bot.event async def on_message(message): - if message.author == client.user: - return + if message.author == discord_bot.user: + return - if message.content.startswith('/issue'): - project.issues.create({'title': message.content.replace("/issue",""),'description': 'Something useful here.'}) + issue_text = message.content.replace("/issue ","") # Получение текста команды «issue» + if message.content.startswith('/issue'): # Создание на базе этого задачи на ГитЛабе и отчёт об этом в канал + if project.issues.create({'title': issue_text,'description': 'Something useful here.'}): + await message.channel.send("Задача «" + issue_text + "» создана.") -client.run("MTA5MjQ3ODUzMTIyNjgzNjk5NA.Gbro_i.C9kbltoL-dCEpNC8e23WHPWnUd5BPaSE4TmWGQ") \ No newline at end of file +discord_bot.run(environ.get("TOKEN_DISCORD")) \ No newline at end of file