开源评论系统ISSO微信通知配置"/>
开源评论系统ISSO微信通知配置
参考链接
.html
根据此链接进行配置时发现在“ISSO配置”这一节有些问题需要解决,在此记录下来。图中红色的两处,第一处的文件路径在哪里对于新手可能会有疑惑,第二处的配置有些问题,见后文详细说明。
文件路径说明
我是通过pip直接安装的isso,所以我直接搜索了/usr/local目录,找到了它:/usr/local/lib/python2.7/dist-packages/isso/ext/notifications.py
修改内容
按照链接中的修改方法,conn.request发送的请求内容没有进行urlencode编码,导致请求返回失败。另外现在最新版的审核URL格式有所变化,这里贴一下我自己的修改。
1. 在文件开头添加2行
import httplib
import urllib
2. 修改notify_new方法
def notify_new(self, thread, comment):if self.admin_notify:body = self.format(thread, comment, None, admin=True)self.sendmail(thread["title"], body, thread, comment)# 从这里开始是我的修改# --modify begin--uri = local("host") + "/id/" + str(comment["id"])key = self.isso.sign(comment["id"])author = comment["author"] or "Anonymous"conn = httplib.HTTPConnection("sc.ftqq")# 这里按自己申请到的webhook填写,最后加了一个问号不要弄丢了,因为后面要拼接其他参数send_msg = "?"# 请求内容需要进行urlencode,否则请求失败# 另外现在审核的链接多了"/id/%i",我这里加上了send_msg = send_msg + urllib.urlencode({'TA_action_on': 1,'TA_title': author,'TA_content': comment["text"].encode('utf-8'),'TA_url_a': self.public_endpoint+ "/id/%i" % comment["id"] + "/activate/"+key,'TA_url_r': self.public_endpoint+ "/id/%i" % comment["id"] + "/delete/"+key,'TA_url_c': str(local("origin")) + str(thread["uri"]) + "#isso-" + str(comment["id"])})headers = { 'content-type': "application/x-www-form-urlencoded" }conn.request("GET", send_msg, headers=headers)r1 = conn.getresponse()logger.info("ftqq:" + str(r1.status) + " " + str(r1.reason))# --modify end--if comment["mode"] == 1:self.notify_users(thread, comment)
3. 重启isso
sudo supervisorctl restart isso
更多推荐
开源评论系统ISSO微信通知配置
发布评论