summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgames_bot.py22
-rwxr-xr-xrecolor_lib.py88
2 files changed, 110 insertions, 0 deletions
diff --git a/games_bot.py b/games_bot.py
new file mode 100755
index 0000000..5d211b4
--- /dev/null
+++ b/games_bot.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+from recolor_lib import accountError, user
+import asyncio
+
+cooldown_time = 5 # nessesary to ensure DOS prevention doesn't kick in
+
+async def main():
+ try:
+ # not real accounts
+ users = await asyncio.gather(
+ user.init('account_example_1', '1234'),
+ user.init('account_example_2', '5678'))
+ except Exception as e:
+ print(e)
+ else:
+ await asyncio.gather(
+ users[0].maximize_money(),
+ users[1].maximize_money())
+ [await u.close() for u in users]
+
+asyncio.run(main())
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()
+