Typecho Wiki
每一个作品都值得被记录

整合Typecho评论通知插件commentToMail增加微信通知

Typecho维基君Typecho教程 • 1630次浏览 • 发布 2019-04-12 • 更新 2019-04-12
极致加速的V2Ray 助您畅享全球网络 & 搬瓦工VPS最新优惠码

整理博客的时候发现邮件不会发送了,检查了一下是启用了Comment2Wechat 微信推送插件之后出现的,然后这个插件还有一个缺点就是自己评论的也会推送,so整合一下把两个插件合二为一

首先修改配置接口 /plugins/CommentToMail/Plugin.php

$form->addInput($titleForGuest->addRule('required', _t('访客接收邮件标题 不能为空')));

下面加入

$key = new Typecho_Widget_Helper_Form_Element_Text('sckey', NULL, NULL, _t('SCKEY'), _t('SCKEY 需要在 <a href="http://sc.ftqq.com/">Server酱</a> 注册<br />
同时,注册后需要在 <a href="http://sc.ftqq.com/">Server酱</a> 绑定你的微信号才能收到推送'));
$form->addInput($key);

然后在 /plugins/CommentToMail/Action.php

$this->authorMail()->sendMail();

上一行插入

//向博主发推送
$sckey = $this->_cfg->sckey;
if(!empty($sckey)){
    $text = "有人在您的博客发表了评论";
    $desp = "**".$this->_email->author."** 在 [「".$this->_email->title."」](".$this->_email->permalink." \"".$this->_email->title."\") 中说到: \n\n > ".$this->_email->text;
    $postdata = http_build_query(array('text' => $text,'desp' => $desp));
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/x-www-form-urlencoded',
            'content' => $postdata
            )
        );
    $context  = stream_context_create($opts);
    $result = file_get_contents('http://sc.ftqq.com/'.$sckey.'.send', false, $context);
}

搞定

博主目前使用的邮件发送插件版本为
CommentToMail 2.0.0 by Byends Upd

广告声明:文内含有的对外跳转链接(包括不限于超链接、二维码、口令等形式),用于传递更多信息,节省甄选时间,结果仅供参考,Typecho.Wiki所有文章均包含本声明。
本文检索关键词:typecho,微信插件,评论插件
厂商投放
添加新评论 »

已有 3 条评论 »

  1. [...]名称简介版本作者 AMP生成AMP/MIP移动标准页面插件0.7.6.1Holmesian AjaxComments嵌套评论Ajax异步提交效果插件1.2.0Byends, Willin Kan AbbrSlug多种算法生成数字文章缩略名插件1.0.0羽叶 AllowIpTypecho可访问后台IP白名单插件1.0.1Fuzqing Announcement仿Emlog博客悬浮式公告栏插件1.0.[...]

  2. 现在还好用不?

    1. 本站目前没有使用这款插件,可以自行测试一下