dragon-bot/app/gitlab.py

35 lines
867 B
Python
Executable File

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(
"https://git.luker.gq/api/v4/projects/3/issues", data=post_args, headers=headers
)
return r.json()["web_url"]
def parse_message(message):
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")