diff options
author | root <root@bpcserver.bpcserver> | 2024-02-27 20:20:57 -0600 |
---|---|---|
committer | root <root@bpcserver.bpcserver> | 2024-02-27 20:20:57 -0600 |
commit | 5e298bdf679c85694847dc75eaf7d2cee3aa767e (patch) | |
tree | da5f41edb273a63dd98b6592608a66fe721f91c4 /recolor_lib.py |
init
Diffstat (limited to 'recolor_lib.py')
-rwxr-xr-x | recolor_lib.py | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/recolor_lib.py b/recolor_lib.py new file mode 100755 index 0000000..3f292e0 --- /dev/null +++ b/recolor_lib.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 + +import re +from math import ceil +from random import randint +import asyncio +import aiohttp +import json + + +class accountError(Exception): + pass + +class user(object): + @classmethod + async def init(cls, username, password): + self = user() + self.rs = aiohttp.ClientSession() + self.username = username + self.cooldown_time = 5 + async with self.rs.post('https://recolor.me/login?json', data = { + 'action':'login', + 'account_name':username, + 'account_password':password, + 'account_cookie':'1'}) as rp: + + print("Getting key for user {}...".format(self.username)) + json = await rp.json(content_type='text/html') + if not json['account_id']: + raise accountError("Failed to login user {}!".format(self.username)) + else: + async with self.rs.get('https://recolor.me/') as homepage: + self.key = re.search("site.my_key = \'(.*)\';", await homepage.text()).groups()[0] + await self.get_bits() + + return(self) + + async def get_bits(self): + async with self.rs.get('https://recolor.me/account') as p: + rp = await p.text() + self.total_bits = int(re.search("site.my_bits = (\d*);", rp).groups()[0]) + self.threashold = int(re.search("site.limit_bits = (\d*);", rp).groups()[0]) + self.daily_bits = int(re.search("site.daily_limit = (\d*);", rp).groups()[0]) + if self.daily_bits >= self.threashold: + self.bitcapped = True + else: + self.bitcapped = False + + + async def beat_games(self): + print("beating games for user {}".format(self.username)) + workers = [] + while not self.bitcapped: + await self.get_bits() + requests_succeeded = 0 + requests_needed = ceil((self.threashold - self.daily_bits) / 50) # 50 is how much we get per game + while requests_needed > requests_succeeded: + await asyncio.sleep(self.cooldown_time) + async with self.rs.post('https://recolor.me/minigames', data = { + 'action':'report', + 'game':'invert', + 'key':self.key + }) as w: + if w.ok: + requests_succeeded += 1 + await self.get_bits() + print("bitcap acheived for {}!".format(self.username)) + + async def complete_polls(self): + print("User {} beating polls...".format(self.username)) + async with self.rs.get('https://recolor.me/polls') as p: + polls = json.loads(re.search('rePoll\.polls = (\[.*\])\;', await p.text()).groups(1)[0]) + for poll in polls: + await self.rs.post("https://recolor.me/?json", data = { + 'page':'polls', + 'action':'vote', + 'key':self.key, + 'poll':poll['repoll_id'], + 'vote':randint(1,2)}) + await asyncio.sleep(self.cooldown_time) + print("User {} done with polls!".format(self.username)) + + async def maximize_money(self): + await self.beat_games() + await self.complete_polls() + async def close(self): + await self.rs.close() + |