We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
weixin.py 关于推送文本消息。解决由于企业微信限制2048字节,导致内容被截断;
def send_text(self, message_list,towxuser): ''' 推送文本消息 ''' messages = WeChat.set_geshi(message_list)[1] max_bytes = 2048 def next_utf8_slice(text, max_bytes): utf8_bytes = text.encode('utf-8') if len(utf8_bytes) <= max_bytes: return text, '' while max_bytes > 0: try: return utf8_bytes[:max_bytes].decode('utf-8'), utf8_bytes[max_bytes:].decode('utf-8') except UnicodeDecodeError: max_bytes -= 1 return '', text def split_message(content): chunks = [] while content: chunk, content = next_utf8_slice(content, max_bytes) chunks.append(chunk) return chunks message_chunks = split_message(messages) response_list = [] for chunk in message_chunks: text_dict = { "touser": towxuser, "msgtype": "text", "agentid": self.agentid, "text": { "content": chunk }, "safe": 0, "enable_id_trans": 0, "enable_duplicate_check": 0, "duplicate_check_interval": 1800 } response_list.append(self.send(text_dict)) return response_list
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: