Commit ade7b1c8 authored by Stenio Araujo's avatar Stenio Araujo
Browse files

Add merge requests and issues

parent 8b118a4b
......@@ -9,9 +9,11 @@ -- search=ztp wi
import base64
import hashlib
import hmac
import json
import os
import sys
import time
from threading import Thread
from flask import request
from flask_api import FlaskAPI, status
......@@ -53,34 +55,77 @@ def slash():
command ="command")
command_text ="text", '').lower()
response_url ="response_url")
if command_text in ACCEPT_MR_KEYWORDS:
return slackish_merge_requests()
t = Thread(
args=(open_merge_requests, "Merge Requests", response_url))
elif command_text in ACCEPT_ISSUES_KEYWORDS:
return slackish_issues()
t = Thread(
args=(open_issues, "Issues", response_url))
return slackish_help(command)
response = {
"response_type": "ephemeral",
"text": "Recolhendo a informação, já já ela chega! :smile:"
return response
def slackish_merge_requests():
return "*Merge Requests*"
def _send_delayed_slackish_items(get_items_method, type_item, response_url):
items_by_group = get_items_method()
msg_lines = ["Open *%s*:\n" % type_item]
for group, items in items_by_group.items():
msg_lines.append("*%s*:" % group)
if not items:
msg_lines.append(" Esse grupo não tem nenhum item aberto!")
for item in items:
title = item["title"]
author = item["author"]["name"]
link = item["web_url"]
upvotes = item["upvotes"]
downvotes = item["downvotes"]
item_msg = " :thumbsup: {} :thumbsdown: {} {} [{}] - {}"
item_msg.format(upvotes, downvotes, title, author, link))
response = json.dumps({
"resposne_type": "in_channel",
"text": '\n'.join(msg_lines)
response = json.dumps({
"response_type": "ephemeral",
"text": "Não consegui a informação. Sorry :slightly_frowning_face:"
def slackish_issues():
return "*Issues*"
headers = {"Content-Type": "application/json"}, data=response)
def slackish_help(command):
msg = "*Merge Requests*:"
for command_text in ACCEPT_MR_KEYWORDS:
msg += "\n %s %s" % (command, command_text)
msg += "\n*Issues*:"
for command_text in ACCEPT_ISSUES_KEYWORDS:
msg += "\n %s %s" % (command, command_text)
return msg
response = {
"resposne_type": "ephemeral",
"text": msg
return response
def _validate_request():
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment