-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprogram.py
132 lines (115 loc) · 7.07 KB
/
program.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import praw
from praw.models import MoreComments
import requests
import json
# log function
def log(text):
if debug: #ensures that we want logs before logging
print(text)
# get config
# refer to this page if you dont understand what youre looking for https://www.reddit.com/wiki/api
json_file = open("config.json")
variables = json.load(json_file)
json_file.close()
debug = variables['debug']
canPost = variables['canPost']
log("client_id " + variables['client_id'])
log("client_secret " + variables['client_secret'])
log("user_agent " + variables['user_agent'])
log("username " + variables['username'])
log("password " + variables['password'])
# reddit instance init
reddit = praw.Reddit(
client_id=variables['client_id'],
client_secret=variables['client_secret'],
user_agent=variables['user_agent'],
username=variables['username'],
password=variables['password']
)
log("Reddit initialized")
# data retrieval
response = requests.get("https://api.stats.golem.network/v1/network/historical/pricing/average").json()
length = len(response)
avgStart = response[length - 1]['start']
avgCpu = response[length - 1]['cpuh']
avgPerH = response[length - 1]['perh']
response = requests.get("https://api.stats.golem.network/v1/network/earnings/24").json()
dayEarnings = response['total_earnings']
response = requests.get("https://api.stats.golem.network/v1/network/online/stats").json()
providers = response['online']
response = requests.get("https://api.stats.golem.network/v1/requestors").json()
top1amount = response[0]["tasks_requested"]
top2amount = response[1]["tasks_requested"]
top3amount = response[2]["tasks_requested"]
top4amount = response[3]["tasks_requested"]
top5amount = response[4]["tasks_requested"]
log("length " + str(length))
log("avgStart " + str(avgStart))
log("avgCpu " + str(avgCpu))
log("avgPerH " + str(avgPerH))
log("dayEarnings " + str(dayEarnings))
log("providers " + str(providers))
log("Top 5 providers " + "\n\nTop 1: " + str(top1amount) + "\n\nTop 2: " + str(top2amount) + "\n\nTtop 3: " + str(top3amount) + "\n\nTop 4: " + str(top4amount) + "\n\nTop 5: " + str(top5amount))
log("OOGA BOOGA!\n\nAverage Start " + str(avgStart) + "\nAverage CPU/hour " + str(avgCpu) + "\nAverage per hour " + str(avgPerH) + "\nDay Earnings(24h) " + str(dayEarnings) + "\nOnline Providers " + str(providers) + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
log("AAAaaaaAAAAaa!!!\n\nAverage Start " + str(avgStart) + "\nAverage CPU/hour " + str(avgCpu) + "\nAverage per hour " + str(avgPerH) + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
log("very money such wow\n\nDay Earnings(24h) " + str(dayEarnings) + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
log("Now this is a lot!\n\nOnline Providers " + str(providers) + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
# reddit shenanigans
subreddit = reddit.subreddit("GolemProject")
# comment logic
for submission in subreddit.new(limit=1):
log(submission.title)
# TODO SUBMISSION TITLE LOGIC
for comment in submission.comments:
canPost = 1
if hasattr(comment,"body"):
comment_lower = comment.body.lower()
log("------------------")
log(comment_lower)
if "!toprequestors" in comment_lower:
for reply in comment.replies:
if "golem-stat-bot" == reply.author.name:
canPost = 0
if canPost:
log("bot wasnt here")
log("----- REPLY -----")
log("SHEEEEEEEEEEEEEEEEESH" + "\n\nTop 5 providers by amount are:" + "\n\ntop 1: " + str(top1amount) + "\n\ntop 2: " + str(top2amount) + "\n\ntop 3: " + str(top3amount) + "\n\ntop 4: " + str(top4amount) + "\n\ntop 5: " + str(top5amount) + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
comment.reply("SHEEEEEEEEEEEEEEEEESH" + "\n\nTop 5 providers by amount are:" + "\n\ntop 1: " + str(top1amount) + "\n\ntop 2: " + str(top2amount) + "\n\ntop 3: " + str(top3amount) + "\n\ntop 4: " + str(top4amount) + "\n\ntop 5: " + str(top5amount) + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
if "!full" in comment_lower:
for reply in comment.replies:
if "golem-stat-bot" == reply.author.name:
canPost = 0
if canPost:
log("bot wasnt here")
log("----- REPLY -----")
log("OOGA BOOGA!\n\nAverage Start " + str(avgStart) + " GLM" + "\n\nAverage CPU/hour " + str(avgCpu) + " GLM" + "\n\nAverage per hour " + str(avgPerH) + " GLM" + "\n\nDay Earnings(24h) " + str(dayEarnings) + " GLM" + "\n\nOnline Providers " + str(providers))
comment.reply("OOGA BOOGA!\n\nAverage Start " + str(avgStart) + " GLM" + "\n\nAverage CPU/hour " + str(avgCpu) + " GLM" + "\n\nAverage per hour " + str(avgPerH) + " GLM" + "\n\nDay Earnings(24h) " + str(dayEarnings) + " GLM" + "\n\nOnline Providers " + str(providers) + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
canPost = 1
if "!average" in comment_lower:
for reply in comment.replies:
if "golem-stat-bot" == reply.author.name:
canPost = 0
if canPost:
log("bot wasnt here")
log("----- REPLY -----")
comment.reply("AAAaaaaAAAAaa!!!\n\nAverage Start " + str(avgStart) + " GLM" + "\n\nAverage CPU/hour " + str(avgCpu) + " GLM" + "\n\nAverage per hour " + str(avgPerH) + " GLM" + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
canPost = 1
if "!earnings" in comment_lower:
for reply in comment.replies:
if "golem-stat-bot" == reply.author.name:
canPost = 0
if canPost:
log("bot wasnt here")
log("----- REPLY -----")
comment.reply("very money such wow\n\nDay Earnings(24h) " + str(dayEarnings) + " GLM" + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
canPost = 1
if "!online" in comment_lower:
for reply in comment.replies:
if "golem-stat-bot" == reply.author.name:
canPost = 0
if canPost:
log("bot wasnt here")
log("----- REPLY -----")
comment.reply("Now this is a lot!\n\nOnline Providers " + str(providers) + "\n\n[Command List](https://siasky.net/AAC1UFWIyuEahU1EdufDtBoRa-fqQ6iYP-aX2aUVAE-ncw)")
canPost = 1
log("Done! Quitting ...")