Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 40264bc

Browse files
committed
fix: delete permanent media
1 parent a777231 commit 40264bc

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

‎channel/wechatmp/active_reply.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ def POST(self):
4242
message,
4343
)
4444
)
45-
rtype = ReplyType.VOICE if wechatmp_msg.msg_type == "voice" else None
45+
if (wechatmp_msg.msg_type == "voice" and conf().get("voice_reply_voice") == True):
46+
rtype = ReplyType.VOICE
47+
else:
48+
rtype = None
4649
context = channel._compose_context(
4750
ContextType.TEXT, message, isgroup=False, desire_rtype=rtype, msg=wechatmp_msg
4851
)

‎channel/wechatmp/passive_reply.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ def POST(self):
4343
and message_id not in channel.request_cnt # insert the godcmd
4444
):
4545
# The first query begin
46-
rtype = ReplyType.VOICE if wechatmp_msg.msg_type == "voice" else None
46+
if (wechatmp_msg.msg_type == "voice" and conf().get("voice_reply_voice") == True):
47+
rtype = ReplyType.VOICE
48+
else:
49+
rtype = None
4750
context = channel._compose_context(
4851
ContextType.TEXT, message, isgroup=False, desire_rtype=rtype, msg=wechatmp_msg
4952
)

‎channel/wechatmp/wechatmp_channel.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def start_loop(self, loop):
6060
loop.run_forever()
6161

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

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

‎channel/wechatmp/wechatmp_client.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ def upload_media(self, media_type, media_file):
117117
"type": media_type
118118
}
119119
files={"media": media_file}
120-
logger.info("[wechatmp] media {} uploaded".format(media_file))
121120
ret = self.wechatmp_request(
122121
method="post",
123122
url=url,
124123
params=params,
125124
files=files
126125
)
126+
logger.debug("[wechatmp] media {} uploaded".format(media_file))
127127
return ret["media_id"]
128128

129129

@@ -134,13 +134,13 @@ def upload_permanent_media(self, media_type, media_file):
134134
"type": media_type
135135
}
136136
files={"media": media_file}
137-
logger.info("[wechatmp] media {} uploaded".format(media_file))
138137
ret = self.wechatmp_request(
139138
method="post",
140139
url=url,
141140
params=params,
142141
files=files
143142
)
143+
logger.debug("[wechatmp] permanent media {} uploaded".format(media_file))
144144
return ret["media_id"]
145145

146146

@@ -149,13 +149,13 @@ def delete_permanent_media(self, media_id):
149149
params={
150150
"access_token": self.get_access_token()
151151
}
152-
logger.info("[wechatmp] media {} deleted".format(media_id))
153152
self.wechatmp_request(
154153
method="post",
155154
url=url,
156155
params=params,
157-
data={"media_id": media_id}
156+
data=json.dumps({"media_id": media_id}, ensure_ascii=False).encode("utf8")
158157
)
158+
logger.debug("[wechatmp] permanent media {} deleted".format(media_id))
159159

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

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /