This commit is contained in:
Roberto Anic Banic 2017-10-16 15:40:23 +00:00
parent 6d200f0ef7
commit 123201c70c
3 changed files with 37 additions and 7 deletions

15
api/ApiResponse.py Normal file
View File

@ -0,0 +1,15 @@
import json
import ApiResult
class ApiResponse(object):
def __init__(self, data):
parsed_data = json.loads(data)
self.code = parsed_data["return_code"]
self.load_results(parsed_data["results"])
def load_results(self, data):
self.results = array()
for id, result_data in data:
self.results.append(ApiResult(id, result_data))

21
api/ApiResult.py Normal file
View File

@ -0,0 +1,21 @@
from datetime import datetime.strptime, date.strftime
class ApiResult(object):
def __init__(self, id, data):
self.id = id
self.title = data["title"]
self.status = data["status"]
self.date = strptime("%Y-%m-%d", data["date"])
self.thread = data["thread"]
self.commit = data["commit"]
self.pr = data["pr"]
def to_chat_string(self):
return "ID:{:9s} Title:{:40s} PR:{:4s} Status:{:8s} Updated:{:10s}".format(
self.id,
self.title,
self.pr,
self.status,
self.date,
strftime("%Y-%m-%d", self.date)
)

8
bot.py
View File

@ -1,5 +1,4 @@
import discord
import asyncio
import requests
import re
import urllib.parse
@ -13,12 +12,7 @@ rpcs3Bot = Bot(command_prefix="!")
pattern = '[A-z]{4}\\d{5}'
@rpcs3Bot.event
asyncio.async
def on_message(message):
async def on_message(message):
if message.author.name == "RPCS3 Bot":
return
try: