<div align="center">
<a href="https://nonebot.dev/">
<img src="https://nonebot.dev/logo.png" width="200" height="200" alt="nonebot">
</a>
# nonebot-plugin-userinfo
_✨ [Nonebot2](https://github.com/nonebot/nonebot2) 用户信息获取插件 ✨_
<p align="center">
<img src="https://img.shields.io/github/license/noneplugin/nonebot-plugin-userinfo" alt="license">
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="Python">
<img src="https://img.shields.io/badge/nonebot-2.0.0+-red.svg" alt="NoneBot">
<a href="https://pypi.org/project/nonebot-plugin-userinfo">
<img src="https://badgen.net/pypi/v/nonebot-plugin-userinfo" alt="pypi">
</a>
</p>
</div>
多平台的用户信息获取插件,可以获取用户名、用户头像等信息
可以获取的信息:
| 字段 | 类型 | 说明 | 默认值 | 备注 |
| ---------------- | ----------------------- | -------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| user_id | `str` | 用户 id | | |
| user_name | `str` | 用户名 | | |
| user_displayname | `Optional[str]` | 用户昵称 | `None` | |
| user_remark | `Optional[str]` | 用户备注 | `None` | |
| user_avatar | `Optional[ImageSource]` | 用户头像 | `None` | [ImageSource](https://github.com/noneplugin/nonebot-plugin-userinfo/blob/main/nonebot_plugin_userinfo/image_source.py) 可通过 `get_image` 获取 `bytes` 结果 |
| user_gender | `str` | 用户性别 | `"unknown"` | |
### 安装
- 使用 nb-cli
```
nb plugin install nonebot_plugin_userinfo
```
- 使用 pip
```
pip install nonebot_plugin_userinfo
```
### 使用
```python
from nonebot_plugin_userinfo import get_user_info
@matcher.handle()
async def handle(bot: Bot, event: Event):
user_info = get_user_info(bot, event, event.get_user_id()) # 获取当前事件主体用户的信息
```
可以用依赖注入的方式使用:
```python
from nonebot_plugin_userinfo import EventUserInfo, UserInfo
@matcher.handle()
async def handle(user_info: UserInfo = EventUserInfo()): # 获取当前事件主体用户的信息
pass
```
```python
from nonebot_plugin_userinfo import BotUserInfo, UserInfo
@matcher.handle()
async def handle(user_info: UserInfo = BotUserInfo()): # 获取Bot用户信息
pass
```
### 支持的 adapter
- [x] OneBot v11
- [x] OneBot v12
- [x] Console
- [x] Kaiheila
- [x] Telegram
- [x] Feishu
- [x] RedProtocol
- [x] Discord
- [x] DoDo
- [x] Satori
- [x] QQ
### 鸣谢
- [nonebot-plugin-send-anything-anywhere](https://github.com/felinae98/nonebot-plugin-send-anything-anywhere) 项目的灵感来源以及部分实现的参考
- [uy/sun](https://github.com/he0119) 感谢歪日佬的技术支持
Raw data
{
"_id": null,
"home_page": "https://github.com/noneplugin/nonebot-plugin-userinfo",
"name": "nonebot_plugin_userinfo",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "meetwq",
"author_email": "meetwq@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/27/9f/73fe36ac4985f8fc8fe165e4f22d6620216eadfd47fff382a9f1e41f4516/nonebot_plugin_userinfo-0.2.4.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n\n <a href=\"https://nonebot.dev/\">\n <img src=\"https://nonebot.dev/logo.png\" width=\"200\" height=\"200\" alt=\"nonebot\">\n </a>\n\n# nonebot-plugin-userinfo\n\n_\u2728 [Nonebot2](https://github.com/nonebot/nonebot2) \u7528\u6237\u4fe1\u606f\u83b7\u53d6\u63d2\u4ef6 \u2728_\n\n<p align=\"center\">\n <img src=\"https://img.shields.io/github/license/noneplugin/nonebot-plugin-userinfo\" alt=\"license\">\n <img src=\"https://img.shields.io/badge/python-3.8+-blue.svg\" alt=\"Python\">\n <img src=\"https://img.shields.io/badge/nonebot-2.0.0+-red.svg\" alt=\"NoneBot\">\n <a href=\"https://pypi.org/project/nonebot-plugin-userinfo\">\n <img src=\"https://badgen.net/pypi/v/nonebot-plugin-userinfo\" alt=\"pypi\">\n </a>\n</p>\n\n</div>\n\n\u591a\u5e73\u53f0\u7684\u7528\u6237\u4fe1\u606f\u83b7\u53d6\u63d2\u4ef6\uff0c\u53ef\u4ee5\u83b7\u53d6\u7528\u6237\u540d\u3001\u7528\u6237\u5934\u50cf\u7b49\u4fe1\u606f\n\n\u53ef\u4ee5\u83b7\u53d6\u7684\u4fe1\u606f\uff1a\n\n| \u5b57\u6bb5 | \u7c7b\u578b | \u8bf4\u660e | \u9ed8\u8ba4\u503c | \u5907\u6ce8 |\n| ---------------- | ----------------------- | -------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| user_id | `str` | \u7528\u6237 id | | |\n| user_name | `str` | \u7528\u6237\u540d | | |\n| user_displayname | `Optional[str]` | \u7528\u6237\u6635\u79f0 | `None` | |\n| user_remark | `Optional[str]` | \u7528\u6237\u5907\u6ce8 | `None` | |\n| user_avatar | `Optional[ImageSource]` | \u7528\u6237\u5934\u50cf | `None` | [ImageSource](https://github.com/noneplugin/nonebot-plugin-userinfo/blob/main/nonebot_plugin_userinfo/image_source.py) \u53ef\u901a\u8fc7 `get_image` \u83b7\u53d6 `bytes` \u7ed3\u679c |\n| user_gender | `str` | \u7528\u6237\u6027\u522b | `\"unknown\"` | |\n\n### \u5b89\u88c5\n\n- \u4f7f\u7528 nb-cli\n\n```\nnb plugin install nonebot_plugin_userinfo\n```\n\n- \u4f7f\u7528 pip\n\n```\npip install nonebot_plugin_userinfo\n```\n\n### \u4f7f\u7528\n\n```python\nfrom nonebot_plugin_userinfo import get_user_info\n\n@matcher.handle()\nasync def handle(bot: Bot, event: Event):\n user_info = get_user_info(bot, event, event.get_user_id()) # \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u4e3b\u4f53\u7528\u6237\u7684\u4fe1\u606f\n```\n\n\u53ef\u4ee5\u7528\u4f9d\u8d56\u6ce8\u5165\u7684\u65b9\u5f0f\u4f7f\u7528\uff1a\n\n```python\nfrom nonebot_plugin_userinfo import EventUserInfo, UserInfo\n\n@matcher.handle()\nasync def handle(user_info: UserInfo = EventUserInfo()): # \u83b7\u53d6\u5f53\u524d\u4e8b\u4ef6\u4e3b\u4f53\u7528\u6237\u7684\u4fe1\u606f\n pass\n```\n\n```python\nfrom nonebot_plugin_userinfo import BotUserInfo, UserInfo\n\n@matcher.handle()\nasync def handle(user_info: UserInfo = BotUserInfo()): # \u83b7\u53d6Bot\u7528\u6237\u4fe1\u606f\n pass\n```\n\n### \u652f\u6301\u7684 adapter\n\n- [x] OneBot v11\n- [x] OneBot v12\n- [x] Console\n- [x] Kaiheila\n- [x] Telegram\n- [x] Feishu\n- [x] RedProtocol\n- [x] Discord\n- [x] DoDo\n- [x] Satori\n- [x] QQ\n\n### \u9e23\u8c22\n\n- [nonebot-plugin-send-anything-anywhere](https://github.com/felinae98/nonebot-plugin-send-anything-anywhere) \u9879\u76ee\u7684\u7075\u611f\u6765\u6e90\u4ee5\u53ca\u90e8\u5206\u5b9e\u73b0\u7684\u53c2\u8003\n- [uy/sun](https://github.com/he0119) \u611f\u8c22\u6b6a\u65e5\u4f6c\u7684\u6280\u672f\u652f\u6301\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Nonebot2 \u7528\u6237\u4fe1\u606f\u83b7\u53d6\u63d2\u4ef6",
"version": "0.2.4",
"project_urls": {
"Homepage": "https://github.com/noneplugin/nonebot-plugin-userinfo",
"Repository": "https://github.com/noneplugin/nonebot-plugin-userinfo"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1e001188d1dafb99a137f9c65cbcd792f9d5eb615872edec32c00a35ae4a7f4b",
"md5": "305c5a74b3d3552ed31d748280631702",
"sha256": "f08dac58759b859f8bf1d1c17e96cdcee92b10613631a430405364a40181f9e4"
},
"downloads": -1,
"filename": "nonebot_plugin_userinfo-0.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "305c5a74b3d3552ed31d748280631702",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 17037,
"upload_time": "2024-04-26T15:25:07",
"upload_time_iso_8601": "2024-04-26T15:25:07.674062Z",
"url": "https://files.pythonhosted.org/packages/1e/00/1188d1dafb99a137f9c65cbcd792f9d5eb615872edec32c00a35ae4a7f4b/nonebot_plugin_userinfo-0.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "279f73fe36ac4985f8fc8fe165e4f22d6620216eadfd47fff382a9f1e41f4516",
"md5": "0531475d119945395cc3519e4db6a10d",
"sha256": "1d49ff00ce38c856be4388fc2a954656f07cc529ce38ef9593e3a0ea40f26b6a"
},
"downloads": -1,
"filename": "nonebot_plugin_userinfo-0.2.4.tar.gz",
"has_sig": false,
"md5_digest": "0531475d119945395cc3519e4db6a10d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 10634,
"upload_time": "2024-04-26T15:25:09",
"upload_time_iso_8601": "2024-04-26T15:25:09.612590Z",
"url": "https://files.pythonhosted.org/packages/27/9f/73fe36ac4985f8fc8fe165e4f22d6620216eadfd47fff382a9f1e41f4516/nonebot_plugin_userinfo-0.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-26 15:25:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "noneplugin",
"github_project": "nonebot-plugin-userinfo",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "nonebot_plugin_userinfo"
}