This repository was archived by the owner on Jun 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblah.py
More file actions
67 lines (65 loc) · 2.66 KB
/
blah.py
File metadata and controls
67 lines (65 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def hk_compiler(channel, message):
# Garbage below test edit
hk_response = await hk.run(blocks[b]["code"], blocks[b]["lang"])
if len(hk_response["run_status"].get("output", "No Output")) <= 1950:
if hk_response["compile_status"] == "OK":
if hk_response["run_status"]["exit_code"] == "9":
lang = "css"
if hk_response["run_status"]["output"] == "":
output = "No Output"
else:
output = hk_response["run_status"]["output"]
react_with = "➰"
elif hk_response["run_status"]["exit_code"] == "0":
lang = "yaml"
if hk_response["run_status"]["output"] == "":
output = "No Output"
else:
output = hk_response["run_status"]["output"]
react_with = "✅"
else:
lang = "http"
output = hk_response["run_status"]["stderr"].replace(" ", "⠀")
react_with = "⚠️"
else:
lang = "diff"
output = "- " + (
hk_response["compile_status"]
.replace("\n", "\n- ")
.replace("```", "`` ")
)
react_with = "❌"
# mes represents the output message
mes = await channel.send(
f"```{lang}\n{output}```Msg ID: **{payload.message_id}**"
)
await mes.add_reaction(react_with)
await mes.add_reaction("🗑️")
def check(reaction, user):
return (
user == message.author
and reaction.message.id == mes.id
and str(reaction.emoji) == "🗑️"
)
try:
reaction, user = await client.wait_for(
"reaction_add", timeout=30.0, check=check
)
except asyncio.TimeoutError:
await mes.clear_reaction("🗑️")
else:
await mes.delete()
else:
try:
if hk_response["compile_status"] == "OK":
if hk_response["run_status"]["exit_code"] == "0":
key = await hastebin.get_key(hk_response["run_status"]["output"])
else:
key = await hastebin.get_key(hk_response["run_status"]["stderr"])
else:
key = await hastebin.get_key(hk_response["compile_status"])
await channel.send(
f"The output is too long. Check it out in http://hastebin.com/{key['key']}"
)
except Exception as err:
await channel.send(err)