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

Commit

Permalink
Fix: 补充插件接收自己消息选项的文档
Browse files Browse the repository at this point in the history
  • Loading branch information
Yinzo committed Jul 9, 2017
1 parent 9d27a18 commit 0ba8a2d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions resources/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ def manager_init(bot):

```

### 选择接收自己发出的消息
机器人在群聊中回复消息的时候,自己也会接收到自己发出的消息。这个消息在插件框架中默认是直接忽略的,如果你需要接受并处理它,请在 Signals 装饰器中指定 `accept_self` 参数为 `True`,这样机器人收到自己的消息的时候也将会转交给这一插件处理。

示例:

```python
@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("#测试内容:"):]))
```


## 插件管理相关

Expand Down

0 comments on commit 0ba8a2d

Please sign in to comment.