Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

增加选项控制插件是否收到自己发出的群消息 #133

Open
elecalion opened this issue Jun 23, 2017 · 2 comments
Open

增加选项控制插件是否收到自己发出的群消息 #133

elecalion opened this issue Jun 23, 2017 · 2 comments

Comments

@elecalion
Copy link

能否增加选项控制插件是否收到自己发出的群消息?

是否过滤自身消息应该由插件自己去判断,而如果从源头过滤掉了消息,插件就没有其他途径获取到了。

@Yinzo
Copy link
Owner

Yinzo commented Jun 23, 2017

Master 分支代码已更新,现在插件装饰器提供了accept_self 参数,默认为 False,可以自定义是否接受自己发出的消息,顺便提供个样例插件供你参考吧

@on_group_message(name='self_test', accept_self=True)
def test2(msg, bot):
    reply = bot.reply_msg(msg, return_function=True)
    prefix = 'test_self'
    if msg.content.startswith(prefix):
        reply("#测试内容:{}".format(msg.content[len(prefix):]))

    if bot.is_self_msg(msg) and msg.content.startswith('#测试内容:'):
        reply("成功收到了自己的消息: {}".format(msg.content[len("#测试内容:"):]))

@winkidney
Copy link
Collaborator

赞啊

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants