Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

功能请求: Python SDK退出功能和手动绑定、解绑处理函数的功能 #8

@SuperMarioSF

Description

@SuperMarioSF

由于一些需求,我需要能够在Python SDK中手动通过CQHttp类的方法来绑定和解绑处理函数,并且无法使用装饰器。
此外,由于相同的需求,我需要能够正确停止掉Python SDK的全部线程。目前是一旦初始化CQHttp对象并调用了run()方法,Bottle总是会有一个线程在后面持续运行不退出,结果导致必须按Ctrl+C终止。

以下是一些方法命名与参数的建议,如果起名困难的话可以参考一下这里。
更新: 重新阅读源码之后发现给出的建议参数列表中有一些不妥之处,已修改。

from typing import Callable, Iterable

class CQHttp(...):
    # 停止本地SDK的线程,如需重新启动bot则需重新启动CQHttp.run()。
    def sdk_local_stop() -> None:
        pass

    # 通过方法注册处理函数
    def set_handler(post_type: str, handler: Callable, types: Iterable=None) -> None:
        pass

    # 通过方法解除已经注册的函数
    def unset_handler(post_type: str, types: Iterable=None) -> None:
        pass

感谢你对本功能请求的关注。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions