1 Star 0 Fork 16

aaron/stock_robot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wx_reply.py 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
邹吉华 提交于 2023-04-12 16:27 +08:00 . 1.6
# -*- coding: utf-8 -*-#
# filename: reply.py
import time
class RepMsg(object):
def __init__(self):
pass
def to_xml(self):
return "success"
class RepTextMsg(RepMsg):
def __init__(self, to_user, from_user, content):
self.__dict = dict()
self.__dict['ToUserName'] = to_user
self.__dict['FromUserName'] = from_user
self.__dict['CreateTime'] = int(time.time())
self.__dict['Content'] = content
def to_xml(self):
XmlForm = """
<xml>
<ToUserName><![CDATA[{ToUserName}]]></ToUserName>
<FromUserName><![CDATA[{FromUserName}]]></FromUserName>
<CreateTime>{CreateTime}</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[{Content}]]></Content>
</xml>
"""
return XmlForm.format(**self.__dict)
class RepImageMsg(RepMsg):
def __init__(self, to_user, from_user, media_id):
self.__dict = dict()
self.__dict['ToUserName'] = to_user
self.__dict['FromUserName'] = from_user
self.__dict['CreateTime'] = int(time.time())
self.__dict['MediaId'] = media_id
def to_xml(self):
XmlForm = """
<xml>
<ToUserName><![CDATA[{ToUserName}]]></ToUserName>
<FromUserName><![CDATA[{FromUserName}]]></FromUserName>
<CreateTime>{CreateTime}</CreateTime>
<MsgType><![CDATA[image]]></MsgType>
<Image>
<MediaId><![CDATA[{MediaId}]]></MediaId>
</Image>
</xml>
"""
return XmlForm.format(**self.__dict)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/alpha_aaron/stock_robot.git
git@gitee.com:alpha_aaron/stock_robot.git
alpha_aaron
stock_robot
stock_robot
master

搜索帮助