浏览代码

fix: delete permanent media

master
JS00000 1年前
父节点
当前提交
40264bc9cb
共有 4 个文件被更改,包括 16 次插入8 次删除
  1. +4
    -1
      channel/wechatmp/active_reply.py
  2. +4
    -1
      channel/wechatmp/passive_reply.py
  3. +2
    -2
      channel/wechatmp/wechatmp_channel.py
  4. +6
    -4
      channel/wechatmp/wechatmp_client.py

+ 4
- 1
channel/wechatmp/active_reply.py 查看文件

@@ -42,7 +42,10 @@ class Query:
message,
)
)
rtype = ReplyType.VOICE if wechatmp_msg.msg_type == "voice" else None
if (wechatmp_msg.msg_type == "voice" and conf().get("voice_reply_voice") == True):
rtype = ReplyType.VOICE
else:
rtype = None
context = channel._compose_context(
ContextType.TEXT, message, isgroup=False, desire_rtype=rtype, msg=wechatmp_msg
)


+ 4
- 1
channel/wechatmp/passive_reply.py 查看文件

@@ -43,7 +43,10 @@ class Query:
and message_id not in channel.request_cnt # insert the godcmd
):
# The first query begin
rtype = ReplyType.VOICE if wechatmp_msg.msg_type == "voice" else None
if (wechatmp_msg.msg_type == "voice" and conf().get("voice_reply_voice") == True):
rtype = ReplyType.VOICE
else:
rtype = None
context = channel._compose_context(
ContextType.TEXT, message, isgroup=False, desire_rtype=rtype, msg=wechatmp_msg
)


+ 2
- 2
channel/wechatmp/wechatmp_channel.py 查看文件

@@ -60,10 +60,10 @@ class WechatMPChannel(ChatChannel):
loop.run_forever()

async def delete_media(self, media_id):
logger.info("[wechatmp] media {} will be deleted in 10s".format(media_id))
logger.debug("[wechatmp] permanent media {} will be deleted in 10s".format(media_id))
await asyncio.sleep(10)
self.client.delete_permanent_media(media_id)
logger.info("[wechatmp] media {} has been deleted".format(media_id))
logger.info("[wechatmp] permanent media {} has been deleted".format(media_id))

def send(self, reply: Reply, context: Context):
receiver = context["receiver"]


+ 6
- 4
channel/wechatmp/wechatmp_client.py 查看文件

@@ -117,13 +117,13 @@ class WechatMPClient:
"type": media_type
}
files={"media": media_file}
logger.info("[wechatmp] media {} uploaded".format(media_file))
ret = self.wechatmp_request(
method="post",
url=url,
params=params,
files=files
)
logger.debug("[wechatmp] media {} uploaded".format(media_file))
return ret["media_id"]


@@ -134,13 +134,13 @@ class WechatMPClient:
"type": media_type
}
files={"media": media_file}
logger.info("[wechatmp] media {} uploaded".format(media_file))
ret = self.wechatmp_request(
method="post",
url=url,
params=params,
files=files
)
logger.debug("[wechatmp] permanent media {} uploaded".format(media_file))
return ret["media_id"]


@@ -149,13 +149,13 @@ class WechatMPClient:
params={
"access_token": self.get_access_token()
}
logger.info("[wechatmp] media {} deleted".format(media_id))
self.wechatmp_request(
method="post",
url=url,
params=params,
data={"media_id": media_id}
data=json.dumps({"media_id": media_id}, ensure_ascii=False).encode("utf8")
)
logger.debug("[wechatmp] permanent media {} deleted".format(media_id))

def clear_quota(self):
url="https://api.weixin.qq.com/cgi-bin/clear_quota"
@@ -168,6 +168,7 @@ class WechatMPClient:
params=params,
data={"appid": self.app_id}
)
logger.debug("[wechatmp] API quata has been cleard")

def clear_quota_v2(self):
url="https://api.weixin.qq.com/cgi-bin/clear_quota/v2"
@@ -176,3 +177,4 @@ class WechatMPClient:
url=url,
data={"appid": self.app_id, "appsecret": self.app_secret}
)
logger.debug("[wechatmp] API quata has been cleard")

正在加载...
取消
保存