歌曲封面 未知作品
  • 歌曲封面Ancient grooverSoundTeMP

友情链接(申请) /RSS订阅/网站地图

本博客托管于刺激云美国服务器

My IP Address

网站已运行 3 年 290 天 18 小时 50 分

Powered by Typecho & Sunny

2 online · 55 ms

歌曲封面 未知作品
  • 歌曲封面Ancient grooverSoundTeMP

友情链接(申请) /RSS订阅/网站地图

本博客托管于刺激云美国服务器

My IP Address

网站已运行 3 年 290 天 18 小时 50 分

Powered by Typecho & Sunny

4 online · 83 ms

晨曦日记 少时不得之物 终将困其一生
Title

利用QQ机器人在有WordPress评论时QQ消息通知

eileen

·

·

664次阅读
网站
Article
引用https://www.boxmoe.com/534.html

项目

go-cqhttp

项目地址

https://github.com/Mrs4s/go-cqhttp

效果

使用

在主题文件夹中的function.php添加以下代码

♾️ php 代码:
function bot_msg_qq($comment_id)
{
    $comment = get_comment($comment_id);
//如果评论作者是管理员,直接返回不处理
    if( user_can($comment->user_id, 'administrator') )
    {
        return;
    }
    $siteurl = get_bloginfo('url');
    $text = '文章《' . get_the_title($comment->comment_post_ID) . '》有新的评论!';
    $desp = $text . "\n" . "作者: $comment->comment_author \n邮箱: $comment->comment_author_email \n评论: $comment->comment_content \n点击查看:$siteurl/?p=$comment->comment_post_ID#comments";
    // 封装Object,message是我们需要推送到 QQ 的消息内容
    $postdata = http_build_query(
        array(
            'message' => $desp
        )
    );
    // 执行POST请求
    $opts = array('http' =>
        array(
            'method' => 'POST',
            'header' => 'Content-type: application/x-www-form-urlencoded',
            'content' => $postdata
        )
    );
    $context = stream_context_create($opts);  
    return $result = file_get_contents('https://bot.zard.hk/send_private_msg?user_id=接收qq号', false, $context);
}
add_action('comment_post', 'bot_msg_qq', 19, 2);
  • 修改QQ机器人的API或者保持默认
  • 修改接收通知的QQ号码
  • QQ机器人与接收通知的QQ号码必须为好友

我的QQ机器人号码 565752347
API: https://bot.zard.hk
务必添加565752347为好友,不然无法接收消息
本人不保证此接口稳定性,如有需求请自建go-cqhttp

typecho插件

https://11.do/543.html

现在已有 1 条评论,3 人点赞
eileen
Comment:共1条
发表
  1. 头像
    @

    博主

    eileen
    🤩🤩🤩好奇怪
    · Windows · Chrome · 中国江苏省扬州市移动

    👍

    💖

    💯

    💦

    😄

    🪙

    👍 1 💖 0 💯 0 💦 0 😄 0 🪙 0
搜 索 消 息 足 迹
你还不曾留言过..
你还不曾留下足迹..
博主 不再显示
博主