def get_listener_task(self): scores = {} for phase in phase_list: answer = self.ask(phase['operator'], phase['question']) scores[phase['answer_type']] = answer self.display_result(scores) redis.delete(get_dark_work_shuang_rank_session_name(self.chatbot_user_id))
def delete(self, user_id, chatbot_user_id): related_listener = self.get_listener(user_id, chatbot_user_id) if related_listener: redis.delete( self.get_dark_listener_session_name(user_id, chatbot_user_id)) related_listener.alive = False del related_listener
def check_lock(self, sender_id): if redis.get( self.get_sign_in_lock_name(sender_id=sender_id)) is not None: redis.delete(self.get_sign_in_lock_name(sender_id=sender_id)) return True else: return False
def shut_down_dark_spy(self, request_json): redis.delete( self.get_dark_spy_session_name(request_json['chatbotUserId'])) chatbots.get(request_json['chatbotUserId']).send_action_card( ActionCard(title="游戏结束", text="### 游戏已经回归虚无......", btns=[CardItem(title="再来一把", url="**游戏:谁是卧底:开启")])) return
def shut_down_guess_number(chatbot_user_id): redis.delete(get_dark_guess_number_session_name(chatbot_user_id)) chatbots.get(chatbot_user_id).send_action_card( ActionCard( title="游戏结束", text="### 数字已经忘记......", btns=[CardItem( title="再来一把", url="**游戏:猜数字:开启")] )) return
def shut_down_work_shuang_rank(chatbot_user_id): redis.delete(get_dark_work_shuang_rank_session_name(chatbot_user_id)) chatbots.get(chatbot_user_id).send_action_card( ActionCard( title="计算已关闭", text="### 计算已关闭......", btns=[CardItem( title="重新计算", url="**工作性价比:开启")] )) return
def treat_dark_quiz(self, answer, type, request_json): redis_data_str = redis.get( self.get_session_name_by_type(request_json['chatbotUserId'], int(type))) if redis_data_str is None: return redis_data = eval(redis_data_str) if redis_data['answer'] == int(answer): chatbots.get(request_json['chatbotUserId']).send_action_card( ActionCard(title="暗黑答题", text="### 回答正确!6六6!", btns=[ CardItem(title="再来一题是非题", url="**游戏:暗黑答题:是非题(10金币)"), CardItem(title="再来一题单选题", url="**游戏:暗黑答题:单选题(20金币)") ])) if type == '0': user_login.rewards_to_sender_id(10, request_json) if type == '1': user_login.rewards_to_sender_id(20, request_json) else: chatbots.get(request_json['chatbotUserId']).send_action_card( ActionCard(title="暗黑答题", text="### GG!回答错误!正确答案是「{0}」,相关信息:{1}".format( redis_data['answer_str'], redis_data['analytic']), btns=[ CardItem(title="再来一题是非题", url="**游戏:暗黑答题:是非题(10金币)"), CardItem(title="再来一题单选题", url="**游戏:暗黑答题:单选题(20金币)") ])) user_login.rewards_to_sender_id(-5, request_json) redis.delete( self.get_session_name_by_type(request_json['chatbotUserId'], int(type)))
#-*- coding=utf-8 -*- import time from config import redis redis_key = "guba_proxy_ips:sorted_set" forbid_ips = set() with open('ip_forbid.txt') as f: for line in f: forbid_ips.add(line.strip()) proxy_ips = set() with open('../proxy_ips.txt') as f: for line in f: proxy_ip = line.strip() if proxy_ip not in forbid_ips: proxy_ips.add(proxy_ip) print 'proxy ip list ', len(proxy_ips), ' push to redis' redis.delete(redis_key) for proxy_ip in proxy_ips: redis.zincrby(redis_key, proxy_ip, amount=1)
def delete_old_modules(): list_module_ids = [m['id'] for m in json.loads(redis.get('module_list'))] redis_keys = redis.keys() for key in redis_keys: if key not in list_module_ids and re.match("^m[0-9]+", key): redis.delete(key)
def shut_down_dark_maze(chatbot_user_id): redis.delete(get_dark_maze_session_name(chatbot_user_id)) chatbots.get(chatbot_user_id).send_text('迷宫已经回归虚无......') return
def clear_listener_session_choices(self, user_id: str, chatbot_user_id: str): redis.delete( self.get_dark_listener_session_name(user_id, chatbot_user_id))