nettirely.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:nettirely 作者: 8Banana 项目源码 文件源码
def on_regexp(self, regexp):
        """
        Creates a decorator that registers a regexp command handler.

        The regexp command handler takes as arguments:
            1. The bot instance
            2. The command sender
            3. The command recipient, usually a channel
            4. The match object, for any groups you might wanna extract.

        The regexp is searched, not just matched.
        Your handler might get called multiple times per message,
        depending on the amount of matches.
        """

        regexp = re.compile(regexp)

        def _inner(func):
            if not inspect.iscoroutinefunction(func):
                raise ValueError("You can only register coroutines!")
            self._regexp_callbacks.setdefault(regexp, [])\
                                  .append(func)
            return func
        return _inner
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号