infini'水系核心

pypi hydro [![.github/workflows/python-publish.yml](https://github.com/HydroRoll-Team/infini/actions/workflows/python-publish.yml/badge.svg)](https://github.com/HydroRoll-Team/infini/actions/workflows/python-publish.yml) [![CodeQL](https://github.com/HydroRoll-Team/infini/actions/workflows/codeql.yml/badge.svg)](https://github.com/HydroRoll-Team/infini/actions/workflows/codeql.yml) [![Netlify Status](https://api.netlify.com/api/v1/badges/ecbe4af3-223f-4fa4-a182-a37a776fd05b/deploy-status)](https://app.netlify.com/sites/grps-v1/deploys)

## 🎁 Getting hydro > [!IMPORTANT] > > 强烈推荐使用 `pdm` 等能创建虚拟环境的包管理工具管理你的 `HydroRollBot` 项目。 1. 安装库 在终端中执行: ```bash git clone https://github.com/HydroRoll-Team/infini.git cd infini pdm install ``` 你可以使用`pip`进行安装: ```bash pip install infini ``` 2. 创建规则包实例 确保你的`infini`正确安装后,打开终端并执行: ``` shell python -m infini new MyRule ``` 你可以在生成的 `MyRule\rule.py` 创建一个或者多个继承 `Handler` 基类的实例, 通过编写合适的相关方法与类注册规则包实现规则的自定义。 ``` python from infini import Handler, Result __handlers__ = ["HandlerRule"] class HandlerRule(Handler): """自设业务函数""" name = "MyRule" # 规则包名 priority: int = 0 # 规则包权重 def process(self, **kwargs) -> Result: """声明规则包检定方式""" return Result("event1", True) ``` `process`函数应当返回一个`Result`对象,它应当包含一个消息事件名(例如示例中的`event1`),该消息事件名应当在 `MyRule\event.py` 中被注册。消息事件的动态内容通过`{name}`的方式声明并通过`name="内容"`的方式实现。 3. 创建你的测试文件 在 `MyRule\tests.py` 中的 `test` 函数中给出测试函数,并返回一个 `list`,应当包含所有异常内容。 4. 测试你的规则包 执行指令: ```bash python -m infini test MyRule ``` ### 🎍Sites _(recommend)_ ~~~~ ## 📄 License [MIT](https://github.com/HydroRoll-Team/infini/blob/master/LICENSE) © 2023-PRESENT [简律纯](https://github.com/HsiangNianian)