-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPython code
95 lines (65 loc) · 1.96 KB
/
Python code
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
#!/usr/bin/python
import praw
import time
import datetime
acc=0
lastID=""
def bot_login():
print("Loggin in...")
r = praw.Reddit(user_agent='Invest bot (by /u/xxxx)',
client_id='xxxxxxxxxxxx', client_secret="xxxxxxxxxxxxxxxxxxxxxx",
username='xxxxxxxx', password='xxxxxxxxxxx')
print("Logged in!")
return r
def bot_login2():
print("Loggin in...")
r2 = praw.Reddit(user_agent='Invest bot (by /u/xxxx)',
client_id='xxxxxxxxxxxx', client_secret="xxxxxxxxxxxxxxxxxxxxxx",
username='xxxxxxxx', password='xxxxxxxxxxx')
print("Logged in!")
return r2
user = ['xx','xx','xx','xx','xx','xx']
def run_bot(r):
#globale variable wird verwendet
global lastID, kommentiert, acc
for us in user:
#1 Kommentar von redditor wird geladen
for comment in r.redditor(us).comments.new(limit=1):
print(us)
#Zeit wird berechnet
now=time.time()
age = now - comment.created_utc
print("Zeit wurde berechnet")
#Wenn alter unter 300 sek dann
if comment.id != age<300:
#wenn !invest kommentiert wurde dann
if "!invest" in comment.body:
#Überschreibt "comment" und setzt den Werd auf den Wert von "parent2" damit
parent = comment.parent_id
parent2 = parent.split('_')[1]
comment = r.comment(parent2)
#Antwortet dem Parentkommentar !invest 100%
comment.reply("!invest 100%")
print("ES WURDE KOMMENTIERT")
#Zählt mit wie vielen accs investiert wurde
acc=acc+1
if (acc==2):
#Wenn Kommentiert wurde macht er nichts für bisschen unter 4 Stunden
print("Sleeping für 14300 sekunden...")
#Sleep für ein bisschen unter 4 Stunden
time.sleep(14300)
acc=0
break
print("Sleeping für 6 sekunden...")
#Sleep für 6
time.sleep(6)
r = bot_login()
r2 = bot_login2()
while True:
try:
run_bot(r)
print("HEY")
run_bot(r2)
except:
print("Error")
time.sleep(10)