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

参考链接

https://zhangnew.com/wechat-check-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.com")
			
            # 这里按自己申请到的webhook填写,最后加了一个问号不要弄丢了,因为后面要拼接其他参数
            send_msg = "http://sc.ftqq.com/webhook/XXXXXX?"
            # 请求内容需要进行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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值