-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhiveos_check_values.py
51 lines (41 loc) · 1.76 KB
/
hiveos_check_values.py
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
import discord
import random
#import asyncio
async def hiveos_check(d_client, msg):
#https://discord.com/channels/973611254696542338/973611807178645564/1001515008515125359
#channel to receive hiveos notifications
if (msg.channel.id != 973611807178645564):
return
print("hiveos check is running")
print(msg.content)
await msg.add_reaction("🧙♂️")
invalid_value_reaction = "⚡"
value_check_counter = 0
#dynamic settings feature will be here in the future
eth_min_value = 40.0
eth_start = "ethash"
msgcontent = msg.content.split(", ")
farm_name = msgcontent[0].split(":", 1)[0]
for msgv in msgcontent:
if msgv.startswith(eth_start):
xvalue = msgv.split(" ")[1] #ethash 47.41 MH/s
print("eth: " + xvalue)
value_check_counter = value_check_counter + 1
if float(xvalue) > eth_min_value:
print("eth: all good")
#await hiveos_alert(d_client, farm_name, "{0} value is correct".format(eth_start))
else:
print("eth: failed")
await msg.add_reaction(invalid_value_reaction)
await hiveos_alert(d_client, farm_name, "{0} value is NOT correct".format(eth_start))
if value_check_counter < 1:
await hiveos_alert(d_client, farm_name, "Unexpected Notification Occurred.")
else:
emoji_list = ["🍷", "🍸", "🍹", "🥃", "☕"]
await msg.add_reaction(random.choice(emoji_list))
async def hiveos_alert(d_client, farmtext, text1):
#https://discord.com/channels/973611254696542338/1001619777996984433/1001620513229127840
server = d_client.get_guild(973611254696542338)
channel = server.get_channel(1001619777996984433)
msg_obj = await channel.fetch_message(1001620513229127840)
await channel.send("Hiveos Alert in {0}:\n{1}".format(farmtext, text1))