Mojo-Weixin icon indicating copy to clipboard operation
Mojo-Weixin copied to clipboard

建议给推送增加“公众号白名单”功能

Open sylingd opened this issue 7 years ago • 1 comments

目前代码里面,如果开启了is_ban_official,则所有公众号消息都不会触发推送

if($msg->type eq 'friend_message'){
    return if $data->{is_ban_official} and $msg->sender->category eq '公众号';
    $msgId = $msg->sender->id;
    $title = $msg->sender->displayname;
    $message = $msg->content;
    $senderType = '1';
}

但是另外几种消息均有不同的判定方式,如:

elsif($msg->type eq 'discuss_message'){
    return if ref $data->{ban_discuss}  eq "ARRAY" and @{$data->{ban_discuss}} and first {$_=~/^\d+$/?$msg->discuss->uid eq $_:$msg->discuss->displayname eq $_} @{$data->{ban_discuss}};
    return if ref $data->{allow_discuss}  eq "ARRAY" and @{$data->{allow_discuss}} and !first {$_=~/^\d+$/?$msg->discuss->uid eq $_:$msg->discuss->displayname eq $_} @{$data->{allow_discuss}};
    $msgId= $msg->discuss->id;
    $title = $msg->discuss->displayname;
    $message = $msg->sender->displayname . ": " . $msg->content;
    $senderType = '3';
}

能否考虑将公众号也改为类似的方式?用于不接收大部分公众号消息推送,只接收某些特定公众号的消息推送(如各类消息通知、某些比较优质的公众号)

sylingd avatar Aug 20 '18 03:08 sylingd

@sylingd 你已经把相关代码都贴出来了 如果动手能力强 建议自己直接改下代码更容易满足自己各种定制化需求,也欢迎提交PR~

hexsum avatar Sep 30 '18 02:09 hexsum