Create issues with dragon-bot now
This commit is contained in:
parent
7134161ed1
commit
fa9957fd38
@ -18,6 +18,7 @@ import eight_ball
|
|||||||
import emoji
|
import emoji
|
||||||
import excuse
|
import excuse
|
||||||
import get_from_reddit
|
import get_from_reddit
|
||||||
|
import gitlab
|
||||||
import help_methods
|
import help_methods
|
||||||
import lewds
|
import lewds
|
||||||
import questions
|
import questions
|
||||||
@ -223,6 +224,12 @@ async def on_message(message):
|
|||||||
)
|
)
|
||||||
await client.send_message(message.channel, invite)
|
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 message.content.startswith('!lewd'):
|
||||||
if 'nsfw' in message.channel.name:
|
if 'nsfw' in message.channel.name:
|
||||||
await client.send_message(
|
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.',
|
'Generates a one time use invite to the current channel.',
|
||||||
'Be quick! It expires in 12 hours'
|
'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': [
|
'lewd': [
|
||||||
'Returns a URL for a lewd image.',
|
'Returns a URL for a lewd image.',
|
||||||
'Can only be used in NSFW channels.',
|
'Can only be used in NSFW channels.',
|
||||||
@ -124,7 +128,7 @@ def get_help_message(method):
|
|||||||
def get_help_embed(client):
|
def get_help_embed(client):
|
||||||
categories = {
|
categories = {
|
||||||
'fun': ['clap', 'birb', 'dog', 'excuse', 'greentext', 'lewd', 'message', 'homepage', 'pout', 'smug'],
|
'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'],
|
'users': ['help', 'invite', 'purge', 'roles', 'source', 'minecraft'],
|
||||||
'admin': ['emoji', 'cleanup']
|
'admin': ['emoji', 'cleanup']
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user