From 5e298bdf679c85694847dc75eaf7d2cee3aa767e Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Feb 2024 20:20:57 -0600 Subject: init --- recolor_lib.py | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 recolor_lib.py (limited to 'recolor_lib.py') 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() + -- cgit v1.2.3