def process_answer(): logger.debug('Tuling answer:\n' + pprint.pformat(answer)) ret = str() if at_member: if len(msg.chat) > 2 and msg.member.name and not self.is_last_member(msg): ret += '@{} '.format(msg.member.name) code = -1 if answer: code = answer.get('code', -1) if code >= 100000: text = answer.get('text') if not text or (text == msg.text and len(text) > 3): text = next_topic() url = answer.get('url') items = answer.get('list', list()) ret += str(text) if url: ret += '\n{}'.format(url) for item in items: ret += '\n\n{}\n{}'.format( item.get('article') or item.get('name'), item.get('detailurl') ) else: ret += next_topic() return ret
def process_answer(): logger.debug('Tuling answer:\n' + pprint.pformat(answer)) ret = str() if at_member: if len(msg.chat ) > 2 and msg.member.name and not self.is_last_member(msg): ret += '@{} '.format(msg.member.name) code = -1 if answer: code = answer.get('code', -1) if code >= 100000: text = answer.get('text') if not text or (text == msg.text and len(text) > 3): text = next_topic() url = answer.get('url') items = answer.get('list', list()) ret += str(text) if url: ret += '\n{}'.format(url) for item in items: ret += '\n\n{}\n{}'.format( item.get('article') or item.get('name'), item.get('detailurl')) else: ret += next_topic() return ret
def reply_text(self, msg): """ 仅返回答复文本 :param msg: Message 对象,或消息文本 :return: 答复文本 """ error_response = ("主人还没给我设置这类话题的回复", ) if isinstance(msg, Message): user_id = get_context_user_id(msg) question = get_text_without_at_bot(msg) else: user_id = "abc" question = msg or "" params = { "question": question, "format": "json", "platform": "custom", "userId": user_id, } resp = self.session.post(self.url, data=params) text = resp.text for err in error_response: if err in text: return next_topic() return text
def reply_text(self, msg): """ 仅返回答复文本 :param msg: Message 对象,或消息文本 :return: 答复文本 """ error_response = ( "主人还没给我设置这类话题的回复", ) if isinstance(msg, Message): user_id = get_context_user_id(msg) question = get_text_without_at_bot(msg) else: user_id = "abc" question = msg or "" params = { "question": question, "format": "json", "platform": "custom", "userId": user_id, } resp = self.session.post(self.url, data=params) text = resp.text for err in error_response: if err in text: return next_topic() return text