diff --git a/conf/config.yaml b/conf/config.yaml index 3655a85..917b3b9 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -4,5 +4,5 @@ SERVER: reconnect_interval: 3 VERSION: - code: 94 - name: 2.0.4 \ No newline at end of file + code: 95 + name: 2.0.5 \ No newline at end of file diff --git a/core/monitor.py b/core/monitor.py index af05f3b..19b5cb7 100644 --- a/core/monitor.py +++ b/core/monitor.py @@ -50,6 +50,7 @@ class Monitor(callback.CallBack): self.init_config = {} self.queue = None self.changeLock = threading.Lock() + self.change_list = [] def bind(self): models.Config.set('host', Client.target_server) @@ -86,7 +87,12 @@ class Monitor(callback.CallBack): return client.info() else: try: - self.onChangEnv(email, 'waiting', '队列中...') + if email in self.change_list: + self.onChangEnv(email, 'changeError', f'{email}已经在登录队列中') + return + else: + self.change_list.append(email) + self.onChangEnv(email, 'waiting', '队列中...') self.changeLock.acquire() self.changeingIn(email) # 转环境的话清理缓存 result, email, password, cookie, user_agent = self.selenium_login(email, password, cookie) @@ -97,6 +103,7 @@ class Monitor(callback.CallBack): self.onChangEnv(email, 'changeError', str(err)) raise err finally: + self.change_list.remove(email) self.changeLock.release() def login(self, email, password, cookie=None, user_agent=None, proxy=None): @@ -209,7 +216,15 @@ class Monitor(callback.CallBack): browser.close() return False, email, password, cookie_, user_agent_ browser.get(mainUrl) - click_list = ['News Feed', 'Friend Requests', 'Notifications', 'Search', 'More'] + page_source = browser.page_source + if 'News Feed' in page_source: + click_list = ['News Feed', 'Friend Requests', 'Notifications', 'Search', 'More'] + elif '动态消息' in page_source: + click_list = ['动态消息', '加好友请求', '通知', '搜索', '更多'] + else: + self.onChangEnv(email, 'changeError', '未知语言类型,请联系小陈添加') + browser.close() + return False, email, password, cookie_, user_agent_ action_list = random.sample(click_list, 5) print('随机动作', action_list) for i, action in enumerate(action_list):