开源评论系统ISSO微信通知配置

编程入门 行业动态 更新时间:2024-10-09 16:29:03

<a href=https://www.elefans.com/category/jswz/34/1770131.html style=开源评论系统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微信通知配置

本文发布于:2024-03-11 21:31:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1729943.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:开源   通知   系统   ISSO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!