Merge branch 'create_gitlab_tickets' into 'master'
Create issues with dragon-bot now, fixes #5 Closes #5 See merge request ldooks/dragon-bot!11
This commit is contained in:
commit
0d5815ceea
@ -18,6 +18,7 @@ import eight_ball
|
||||
import emoji
|
||||
import excuse
|
||||
import get_from_reddit
|
||||
import gitlab
|
||||
import help_methods
|
||||
import lewds
|
||||
import questions
|
||||
@ -223,6 +224,12 @@ async def on_message(message):
|
||||
)
|
||||
await client.send_message(message.channel, invite)
|
||||
|
||||
if message.content.startswith('!issue'):
|
||||
await client.send_message(
|
||||
message.channel,
|
||||
gitlab.parse_message(message)
|
||||
)
|
||||
|
||||
if message.content.startswith('!lewd'):
|
||||
if 'nsfw' in message.channel.name:
|
||||
await client.send_message(
|
||||
|
44
app/gitlab.py
Normal file
44
app/gitlab.py
Normal file
@ -0,0 +1,44 @@
|
||||
import requests
|
||||
import os
|
||||
|
||||
import help_methods
|
||||
import role_check
|
||||
|
||||
|
||||
def create_issue(title, description):
|
||||
|
||||
post_args = {
|
||||
'title': title,
|
||||
'description': description
|
||||
}
|
||||
|
||||
headers = {
|
||||
'PRIVATE-TOKEN': os.getenv('gitlab_token')
|
||||
}
|
||||
|
||||
r = requests.post(
|
||||
'http://luker.zzzz.io/gitlab/api/v4/projects/2/issues',
|
||||
data=post_args,
|
||||
headers=headers
|
||||
)
|
||||
|
||||
return(r.json()['web_url'])
|
||||
|
||||
|
||||
def parse_message(message):
|
||||
if not role_check.is_admin(message.author.roles):
|
||||
return 'You dont have permission to do that'
|
||||
|
||||
if len(message.content.split()) == 1:
|
||||
return help_methods.get_help_message(method='issue')
|
||||
|
||||
try:
|
||||
message = ' '.join(message.content.split()[1:])
|
||||
title, description = message.split(';')
|
||||
except Exception:
|
||||
return help_methods.get_help_message(method='issue')
|
||||
|
||||
try:
|
||||
return create_issue(title=title, description=description)
|
||||
except Exception:
|
||||
return help_methods.get_help_message(method='issue')
|
@ -69,6 +69,10 @@ def get_help_message(method):
|
||||
'Generates a one time use invite to the current channel.',
|
||||
'Be quick! It expires in 12 hours'
|
||||
],
|
||||
'issue': [
|
||||
'Creates an issue on gitlab with the passed in parameters\n',
|
||||
'Usage: !issue <issue title>; <issue description>',
|
||||
],
|
||||
'lewd': [
|
||||
'Returns a URL for a lewd image.',
|
||||
'Can only be used in NSFW channels.',
|
||||
@ -124,7 +128,7 @@ def get_help_message(method):
|
||||
def get_help_embed(client):
|
||||
categories = {
|
||||
'fun': ['clap', 'birb', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'homepage', 'pout', 'smug'],
|
||||
'util': ['8ball', 'decide', 'wallpaper', 'weather', 'stock', 'tts'],
|
||||
'util': ['8ball', 'decide', 'wallpaper', 'weather', 'stock', 'tts', 'issue'],
|
||||
'users': ['help', 'invite', 'purge', 'roles', 'source', 'minecraft'],
|
||||
'admin': ['emoji', 'cleanup']
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user