summaryrefslogtreecommitdiff
path: root/post_bot.py
blob: d75912f557e19ac43e732d3e4becf2617674b6d5 (plain)
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
#!/usr/bin/env python3
import requests
import re
from time import sleep
from datetime import datetime, timezone
from os import fork
from threading import Timer

post_cooloff = 7

rs = requests.session()
rp = rs.post('https://recolor.me/login?json', data = {
    'action':'login', 
    'account_name':'testingaccount1', 
    'account_password':'1234',
    'account_cookie':'1'})

if not rp.json()['account_id']:
    print("wrong login info!")
    exit(1)

rp = rs.get('https://recolor.me/')
key_pos = rp.text.find("site.my_key = \'") + len("site.my_key =  ")
#key = rp.text[key_pos:key_pos+32]
key = re.search("site.my_key = \'(.*)\';", rp.text).groups()[0]


def acheive_limit():
    uncaped = True
    check_space = 20
    on_post = check_space

    while uncaped:
        print("starting again!!!!")
        sleep(7)
        on_post += 1

        if on_post > check_space:
            on_post = 0
            rp = rs.get('https://recolor.me/account')
            bits = re.search("site.my_bits = (\d*);", rp.text).groups()[0]
            bit_limit = re.search("site.limit_bits = (\d*);", rp.text).groups()[0]
            daily_limit = re.search("site.daily_limit = (\d*);", rp.text).groups()[0]
            limit_percentage = int((int(daily_limit) / int(bit_limit)) * 100)
            print("total bits: {}\nbit cap: {}/{}\t\t{}%".format(bits, daily_limit, bit_limit, limit_percentage))

            if daily_limit == bit_limit:
                uncaped = False
                rs.post('https://recolor.me/topic/1557621', data={
                    'key':key,
                    'page':'topic',
                    'action':'reply',
                    'topic_id':'1557621',
                    'reply_message':"Done for today!\nSleeping until 06:00 UTC.".format("04:00"),
                    'box_color':'#0000ff',
                    'post_color':'#0',
                    'post_style':'0'
                    })
     
        rs.post('https://recolor.me/topic/1557621', data={
            'key':key,
            'page':'topic',
            'action':'reply',
            'topic_id':'1557621',
            'reply_message':"Daily quota: {}/{}\t{}%\nLast checked {} messages ago\nNext check is {} messages from now".format(daily_limit, bit_limit, limit_percentage, on_post, check_space - on_post),
            'box_color':'#0000ff',
            'post_color':'#0',
            'post_style':'0'
            })

acheive_limit()

while True:
    current_time = datetime.now(timezone.utc)
    desired_time = current_time.replace(day=current_time.day+1, hour=6, minute=0, second=0, microsecond=0)
    print("starting next run at {}".format(str(desired_time)))
    cap_thread = Timer((desired_time - current_time).seconds+1, acheive_limit)
    cap_thread.start()
    cap_thread.join()
    

#usually resets at 11