Skip to content
This repository was archived by the owner on Mar 24, 2023. It is now read-only.

Commit 2ec402c

Browse files
author
berrysauce
committed
Added status command
1 parent 719c5bb commit 2ec402c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# PyCharm
132+
.idea/

main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ def createissue(title, body=None, labels=None):
5959
print ('Response:', r.content)
6060
return 0
6161

62+
def checkissue(num):
63+
url = 'https://api.github.com/repos/StopModReposts/Illegal-Mod-Sites/issues/{0}'.format(num)
64+
r = requests.get(url)
65+
66+
if r.status_code == 200:
67+
print ('Successfully fetched Issue {0}'.format(num))
68+
jsondata = json.loads(r.text)
69+
return r.status_code, jsondata.get("state"), jsondata.get("title")
70+
else:
71+
print ('Could not create Issue {0}'.format(num))
72+
print ('Response:', r.content)
73+
return r.status_code, "N/A", "N/A"
74+
6275

6376
# Bot commands
6477
@bot.event
@@ -115,5 +128,15 @@ async def check(ctx, url: str):
115128
else:
116129
await ctx.send("Error with your request - {0}".format(check))
117130

131+
132+
@bot.command(description="Check the status of a GitHub issue", help="Check the status of a GitHub issue")
133+
async def status(ctx, num: int):
134+
code, status, title = checkissue(num)
135+
if code == 200:
136+
await ctx.send("Issue #{0} ({1}) - Status: {2}".format(num, title, status))
137+
else:
138+
await ctx.send("Error with your request - Status code: {0}".format(code))
139+
140+
118141
# Run bot
119142
bot.run(DISCORD_TOKEN)

0 commit comments

Comments
 (0)