Skip to main content

The `Core` of `HydroRoll`, the `Loader` of your rules packages.

Project description

infini'水系核心

pypi hydro

.github/workflows/python-publish.yml CodeQL Netlify Status

🎁 Getting hydro

[!IMPORTANT]

强烈推荐使用 pdm 等能创建虚拟环境的包管理工具管理你的 HydroRollBot 项目。

  1. 安装库

    在终端中执行:

    git clone https://github.com/HydroRoll-Team/infini.git
    cd infini
    pdm install
    

    你可以使用pip进行安装:

    pip install infini
    
  2. 创建规则包实例

    创建cli.py并写入以下内容:

    import infini
    
    client = infini.Cli()
    client.parse_args()
    

    打开终端并执行:

    python cli.py --new --path MyRule
    

    你可以在生成的 MyRule\rule.py 创建一个或者多个 rule 实例并继承 Rule 基类, 通过编写合适的相关方法与类注册规则包实现规则的自定义。

    from infini import Rule, Result, Dice
    
    class MyRule(Rule):
        """自设规则包"""
    
        name = "MyRule"
        priority: int = 0
    
        def __init__(self) -> None:
            """初始化你的规则包"""
    
        def check(self, dice: Dice) -> Result:
            """声明规则包检定方式"""
            return Result("event1", True)
    

    check函数应当返回一个Result对象,它应当包含一个消息事件名(例如示例中的event1),该消息事件名应当在 MyRule\event.py 中被注册。消息事件的动态内容通过{name}的方式声明并通过name="内容"的方式实现。

  3. 合理修改你的 config.toml 配置文件,完成注册!

🎍Sites

https://grps.hydroroll.team (recommend)
https://grps-v1.netlify.app
https://hydroroll-team.github.io/infini/

📄 License

MIT © 2023-PRESENT 简律纯

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infini-1.0.4.tar.gz (608.1 kB view hashes)

Uploaded Source

Built Distribution

infini-1.0.4-py3-none-any.whl (554.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page