From 679515ca84fef8585fcd10bf925291d5006f65b1 Mon Sep 17 00:00:00 2001 From: BFlow Date: Wed, 25 Mar 2020 18:01:05 +0100 Subject: [PATCH] add command issue --- kabot/kabot/kabot.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/kabot/kabot/kabot.py b/kabot/kabot/kabot.py index a155942..495968a 100644 --- a/kabot/kabot/kabot.py +++ b/kabot/kabot/kabot.py @@ -9,6 +9,7 @@ import requests import aiocron import asyncio import giphy_client +import gitlab from time import sleep from discord.ext import tasks, commands @@ -131,6 +132,36 @@ class Mybot(commands.Cog): else: await ctx.channel.send(random.choice(slap_multiple) % user) + @commands.command(help="Interrogation issues") + async def issue(self, ctx, *args): + if args: + args = list(args) + gl = gitlab.Gitlab('https://git.0w.tf/', private_token='VHLsCQTcjF3oxujqFRYz') + gl.auth() + if args[0] == 'list': + projects = gl.projects.list(search='Kabot')[0] + await ctx.channel.send(projects.name) + issues = projects.issues.list() + for issue in issues: + if "closed" == issue.state: + pass + else: + await ctx.channel.send('Issue: %s' % issue.title) + elif args[0] == 'search': + query = ''.join(args[1:]) + find_issues = gl.search("issues", query) + for issue in find_issues: + await ctx.channel.send("#" + str(issue['id']) + ": " + issue['title'] + '\n' + issue['web_url']) + elif args[0] == 'add': + title = ' '.join(args[1:]) + projects = gl.projects.list() + for project in projects: + if "Kabot" == project.name: + issue = project.issues.create({'title': title}) + await ctx.channel.send(issue.web_url) + else: + await ctx.channel.send('unknown command') + @commands.command(help="optionnal args : [livre] [character]") async def kaamelott(self, ctx, *args): response = None