nonebot-plugin-report


Namenonebot-plugin-report JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://github.com/syrinka/nonebot-plugin-report
SummaryPush message from anywhere to your bot through webhook.
upload_time2024-03-10 09:44:47
maintainer
docs_urlNone
authorsyrinka
requires_python>=3.8.0,<4.0.0
licenseAGPL-3.0
keywords nonebot nonebot2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

# nonebot-plugin-report

</div>

## 功能

该插件提供了一个位于 `/report` 的路由,通过此路由可直接向用户推送消息,实现消息推送机器人的功能

## 使用

请求体示例
```json
{
    "token": "your token here",
    "title": "report title",
    "content": "report content",
    "send_to": "send to"
}
```

### 字段

Field | Type | Desc
-- | -- | --
`token` | `Optional[str]` | 令牌;<br/>当与设置的 `REPORT_TOKEN` 相同时才会推送消息,否则返回 403
`title` | `Optional[str]` | 消息标题
`content` | `str` | 消息内容,*必需字段*
`send_from` | `Optional[ID]` | 推送消息的机器人 ID;<br/>若不设置,任意获取一个可用的机器人
`send_to` | `Optional[ID \| List[ID]]` | 推送用户 `user_id`;<br/>若为 `null` 则推送给所有超管;
`send_to_group` | `Optional[ID \| List[ID]]` | 推送群组 `group_id`

### 别名

部分字段提供有较短的别名:

Field | Alias
-- | --
`send_from` | `from`
`send_to` | `to`
`send_to_group` | `to_group`

别名的优先度低于原名,当且仅当原名未传入时,才会检查别名

### 配置

Field | Type | Desc | Default
-- | -- | -- | --
`REPORT_TOKEN` | `Optional[str]` | 令牌,若不设置则不会进行验证,所有人都可以触发 webhook |
`REPORT_FROM` | `Optional[ID]` | `send_from` 的默认值
`REPORT_ROUTE` | `str` | 路由,若与其它路由冲突可以更换该值,| `/report`
`REPORT_TEMPLATE` | `str` | 消息模板,支持 `title` 与 `content` 两个字段,| `{title}\n{content}`

## 使用例

### python

```bash
import requests
data = {'token': '...', 'content': '...'}
requests.post('http://127.0.0.1:8080/report', json=data)
```

### curl

```bash
curl -L -X POST \
     -d '{"token": "...", "content": "..."}' \
     -H "Content-Type: application/json" \
     -- http://127.0.0.1:8080/report
```

### todo

- [x] 支持设置消息模板

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/syrinka/nonebot-plugin-report",
    "name": "nonebot-plugin-report",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.0,<4.0.0",
    "maintainer_email": "",
    "keywords": "nonebot,nonebot2",
    "author": "syrinka",
    "author_email": "syrinka@foxmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f2/74/6145133693a01b4b37b3ceb9723e80eca60815245bf9db7a79afcaa40338/nonebot_plugin_report-1.3.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n# nonebot-plugin-report\n\n</div>\n\n## \u529f\u80fd\n\n\u8be5\u63d2\u4ef6\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4f4d\u4e8e `/report` \u7684\u8def\u7531\uff0c\u901a\u8fc7\u6b64\u8def\u7531\u53ef\u76f4\u63a5\u5411\u7528\u6237\u63a8\u9001\u6d88\u606f\uff0c\u5b9e\u73b0\u6d88\u606f\u63a8\u9001\u673a\u5668\u4eba\u7684\u529f\u80fd\n\n## \u4f7f\u7528\n\n\u8bf7\u6c42\u4f53\u793a\u4f8b\n```json\n{\n    \"token\": \"your token here\",\n    \"title\": \"report title\",\n    \"content\": \"report content\",\n    \"send_to\": \"send to\"\n}\n```\n\n### \u5b57\u6bb5\n\nField | Type | Desc\n-- | -- | --\n`token` | `Optional[str]` | \u4ee4\u724c\uff1b<br/>\u5f53\u4e0e\u8bbe\u7f6e\u7684 `REPORT_TOKEN` \u76f8\u540c\u65f6\u624d\u4f1a\u63a8\u9001\u6d88\u606f\uff0c\u5426\u5219\u8fd4\u56de 403\n`title` | `Optional[str]` | \u6d88\u606f\u6807\u9898\n`content` | `str` | \u6d88\u606f\u5185\u5bb9\uff0c*\u5fc5\u9700\u5b57\u6bb5*\n`send_from` | `Optional[ID]` | \u63a8\u9001\u6d88\u606f\u7684\u673a\u5668\u4eba ID\uff1b<br/>\u82e5\u4e0d\u8bbe\u7f6e\uff0c\u4efb\u610f\u83b7\u53d6\u4e00\u4e2a\u53ef\u7528\u7684\u673a\u5668\u4eba\n`send_to` | `Optional[ID \\| List[ID]]` | \u63a8\u9001\u7528\u6237 `user_id`\uff1b<br/>\u82e5\u4e3a `null` \u5219\u63a8\u9001\u7ed9\u6240\u6709\u8d85\u7ba1\uff1b\n`send_to_group` | `Optional[ID \\| List[ID]]` | \u63a8\u9001\u7fa4\u7ec4 `group_id`\n\n### \u522b\u540d\n\n\u90e8\u5206\u5b57\u6bb5\u63d0\u4f9b\u6709\u8f83\u77ed\u7684\u522b\u540d\uff1a\n\nField | Alias\n-- | --\n`send_from` | `from`\n`send_to` | `to`\n`send_to_group` | `to_group`\n\n\u522b\u540d\u7684\u4f18\u5148\u5ea6\u4f4e\u4e8e\u539f\u540d\uff0c\u5f53\u4e14\u4ec5\u5f53\u539f\u540d\u672a\u4f20\u5165\u65f6\uff0c\u624d\u4f1a\u68c0\u67e5\u522b\u540d\n\n### \u914d\u7f6e\n\nField | Type | Desc | Default\n-- | -- | -- | --\n`REPORT_TOKEN` | `Optional[str]` | \u4ee4\u724c\uff0c\u82e5\u4e0d\u8bbe\u7f6e\u5219\u4e0d\u4f1a\u8fdb\u884c\u9a8c\u8bc1\uff0c\u6240\u6709\u4eba\u90fd\u53ef\u4ee5\u89e6\u53d1 webhook |\n`REPORT_FROM` | `Optional[ID]` | `send_from` \u7684\u9ed8\u8ba4\u503c\n`REPORT_ROUTE` | `str` | \u8def\u7531\uff0c\u82e5\u4e0e\u5176\u5b83\u8def\u7531\u51b2\u7a81\u53ef\u4ee5\u66f4\u6362\u8be5\u503c\uff0c| `/report`\n`REPORT_TEMPLATE` | `str` | \u6d88\u606f\u6a21\u677f\uff0c\u652f\u6301 `title` \u4e0e `content` \u4e24\u4e2a\u5b57\u6bb5\uff0c| `{title}\\n{content}`\n\n## \u4f7f\u7528\u4f8b\n\n### python\n\n```bash\nimport requests\ndata = {'token': '...', 'content': '...'}\nrequests.post('http://127.0.0.1:8080/report', json=data)\n```\n\n### curl\n\n```bash\ncurl -L -X POST \\\n     -d '{\"token\": \"...\", \"content\": \"...\"}' \\\n     -H \"Content-Type: application/json\" \\\n     -- http://127.0.0.1:8080/report\n```\n\n### todo\n\n- [x] \u652f\u6301\u8bbe\u7f6e\u6d88\u606f\u6a21\u677f\n",
    "bugtrack_url": null,
    "license": "AGPL-3.0",
    "summary": "Push message from anywhere to your bot through webhook.",
    "version": "1.3.0",
    "project_urls": {
        "Homepage": "https://github.com/syrinka/nonebot-plugin-report",
        "Repository": "https://github.com/syrinka/nonebot-plugin-report"
    },
    "split_keywords": [
        "nonebot",
        "nonebot2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1777a3b8c1d0fc71d6e92845b2cc125c92cef83f92ea5392cefdacd84e9aaa93",
                "md5": "9cbc526eb108f49cba4b27369c9306e1",
                "sha256": "d87954e8149256181636688e010832c8c06129ecbec201a73d811bdccba1ce58"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_report-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9cbc526eb108f49cba4b27369c9306e1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0,<4.0.0",
            "size": 15953,
            "upload_time": "2024-03-10T09:44:45",
            "upload_time_iso_8601": "2024-03-10T09:44:45.338348Z",
            "url": "https://files.pythonhosted.org/packages/17/77/a3b8c1d0fc71d6e92845b2cc125c92cef83f92ea5392cefdacd84e9aaa93/nonebot_plugin_report-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2746145133693a01b4b37b3ceb9723e80eca60815245bf9db7a79afcaa40338",
                "md5": "bda30f768bfe2452440546777761c49f",
                "sha256": "85689014dfc97a15be3d38e2d4390e9af0918a7ae5c4a6dc14603d234809891b"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_report-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bda30f768bfe2452440546777761c49f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0,<4.0.0",
            "size": 15320,
            "upload_time": "2024-03-10T09:44:47",
            "upload_time_iso_8601": "2024-03-10T09:44:47.610662Z",
            "url": "https://files.pythonhosted.org/packages/f2/74/6145133693a01b4b37b3ceb9723e80eca60815245bf9db7a79afcaa40338/nonebot_plugin_report-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-10 09:44:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "syrinka",
    "github_project": "nonebot-plugin-report",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "nonebot-plugin-report"
}
        
Elapsed time: 0.19641s