From fd9bf2765c77f86ae75d6c28b5f23614cd14e031 Mon Sep 17 00:00:00 2001 From: Xairooo Date: Wed, 26 Jul 2017 06:25:47 +0200 Subject: [PATCH 1/3] Update MultiBotConfig.json.example --- configs/MultiBotConfig.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/MultiBotConfig.json.example b/configs/MultiBotConfig.json.example index f161b8b1d5..c0494cd138 100644 --- a/configs/MultiBotConfig.json.example +++ b/configs/MultiBotConfig.json.example @@ -9,7 +9,7 @@ "CompleteTutorialNickName": true, "WebSocket": { "IP": "127.0.0.1", - "Port": "4000" + "Port": 4000 }, "walker_limit_output": true } From 3504f47653a80a4dbce7fbade749a7840067c17a Mon Sep 17 00:00:00 2001 From: Xairooo Date: Wed, 26 Jul 2017 08:51:02 +0200 Subject: [PATCH 2/3] Update MultiBotConfig.json.example --- configs/MultiBotConfig.json.example | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/MultiBotConfig.json.example b/configs/MultiBotConfig.json.example index c0494cd138..140818cc72 100644 --- a/configs/MultiBotConfig.json.example +++ b/configs/MultiBotConfig.json.example @@ -8,6 +8,7 @@ "ConfigJsonFile": "config.json", "CompleteTutorialNickName": true, "WebSocket": { + "start_embedded_server": false, "IP": "127.0.0.1", "Port": 4000 }, From 4e40e535b079b309ecc1e7cc5509c953351001e5 Mon Sep 17 00:00:00 2001 From: Xairooo Date: Wed, 26 Jul 2017 08:51:51 +0200 Subject: [PATCH 3/3] Update MultiBot.py --- MultiBot.py | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/MultiBot.py b/MultiBot.py index e2069af3b0..795812fc00 100644 --- a/MultiBot.py +++ b/MultiBot.py @@ -2,6 +2,7 @@ # the above tag defines encoding for this document and is for Python 2.x compatibility import gzip import json +import multiprocessing import os import platform import re @@ -17,12 +18,15 @@ hashkeyCur = 0 accountNum = 0 try: - os.stat('configs/temp') + os.rmdir('configs/temp') except: - os.mkdir('configs/temp') + pass +try: + os.mkdir('configs/temp') +except: + pass AccountLock = Semaphore(value=1) MultiBotConfig = json.loads(open('configs/MultiBotConfig.json').read()) -ThreadNum = MultiBotConfig[u'Threads'] def getProxy(): try: @@ -89,11 +93,9 @@ def AccountManager(Account=None): Accounts.append(Account) AccountLock.release() -def MakeConf(CurThread): +def MakeConf(CurThread, username, password): try: jsonData = json.loads(open('configs/' + MultiBotConfig[u'AuthJsonFile']).read()) - Account = AccountManager() - username, password = Account.split(':') jsonData[u'username'] = username jsonData[u'password'] = password jsonData[u'hashkey'] = getHashKey() @@ -111,9 +113,10 @@ def MakeConf(CurThread): except: pass try: - jsonData[u'websocket'][u'server_url'] = MultiBotConfig[u'WebSocket'][u'IP'] + ':' + str(MultiBotConfig[u'WebSocket'][u'Port'] + CurThread) + if jsonData[u'websocket'][u'start_embedded_server']: + jsonData[u'websocket'][u'server_url'] = MultiBotConfig[u'WebSocket'][u'IP'] + ':' + str(MultiBotConfig[u'WebSocket'][u'Port'] + CurThread) except: - pass + print 'error websocket' with open('configs/temp/config-' + str(CurThread) + '.json', 'w') as s: s.write(json.dumps(jsonData)) @@ -121,32 +124,34 @@ def MakeConf(CurThread): except IOError: print 'config file error' + time.sleep(30) class ThreadClass(threading.Thread): def run(self): - CurThread = int(self.getName().replace('Thread-', '')) -1 + self.CurThread = int(self.getName().replace('Thread-', '')) -1 while True: - Account = AccountManager() - username, password = Account.split(':') + self.Account = AccountManager() + self.username, self.password = self.Account.split(':') + print 'Thread-{0} using account {1}'.format(self.CurThread, self.username) try: - MakeConf(CurThread) + MakeConf(self.CurThread, self.username, self.password) if MultiBotConfig[u'UseProxy']: - proxy = getProxy() + self.proxy = getProxy() if platform.system() == "Linux": - os.system('export HTTP_PROXY="http://' + proxy + '"; export HTTPS_PROXY="https://' + proxy + '"') + self.os.system('export HTTP_PROXY="http://' + proxy + '"; export HTTPS_PROXY="https://' + proxy + '"') if platform.system() == "Windows": - os.system('') + self.os.system('') os.system( "python pokecli.py -af configs/temp/auth-{0}.json -cf configs/temp/config-{0}.json --walker_limit_output {1}".format( - CurThread, MultiBotConfig[u'walker_limit_output'])) + self.CurThread, MultiBotConfig[u'walker_limit_output'])) except Exception as e: import traceback print("Generic Exception: " + traceback.format_exc()) finally: - AccountManager(Account) + AccountManager(self.Account) time.sleep (60) def start(): - for i in range(ThreadNum): + for i in range(MultiBotConfig[u'Threads']): t = ThreadClass() time.sleep (0.1) t.start()