mirror of
https://github.com/RPCS3/discord-bot.git
synced 2025-01-26 20:54:48 +00:00
Fix
This commit is contained in:
parent
6d200f0ef7
commit
123201c70c
15
api/ApiResponse.py
Normal file
15
api/ApiResponse.py
Normal 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
21
api/ApiResult.py
Normal 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
8
bot.py
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user