Nonebot2 用户信息获取插件
Project description
多平台的用户信息获取插件,可以获取用户名、用户头像等信息
可以获取的信息:
字段 | 类型 | 说明 | 默认值 | 备注 |
---|---|---|---|---|
user_id | str |
用户 id | ||
user_name | str |
用户名 | ||
user_displayname | Optional[str] |
用户昵称 | None |
|
user_remark | Optional[str] |
用户备注 | None |
|
user_avatar | Optional[ImageSource] |
用户头像 | None |
ImageSource 可通过 get_image 获取 bytes 结果 |
user_gender | str |
用户性别 | "unknown" |
安装
- 使用 nb-cli
nb plugin install nonebot_plugin_userinfo
- 使用 pip
pip install nonebot_plugin_userinfo
使用
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()) # 获取当前事件主体用户的信息
可以用依赖注入的方式使用:
from nonebot_plugin_userinfo import EventUserInfo, UserInfo
@matcher.handle()
async def handle(user_info: UserInfo = EventUserInfo()): # 获取当前事件主体用户的信息
pass
from nonebot_plugin_userinfo import BotUserInfo, UserInfo
@matcher.handle()
async def handle(user_info: UserInfo = BotUserInfo()): # 获取Bot用户信息
pass
支持的 adapter
OneBot v11 | OneBot v12 | Console | Kaiheila | QQ Guild | Telegram |
---|---|---|---|---|---|
✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
鸣谢
- nonebot-plugin-send-anything-anywhere 项目的灵感来源以及部分实现的参考
- uy/sun 感谢歪日佬的技术支持
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for nonebot_plugin_userinfo-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ce52e73b368364d05aa2c77971afedaef55a28500c8493aca326fa204582757 |
|
MD5 | 08ec89d384b7786f5df9f6974e8c352a |
|
BLAKE2b-256 | b6f27ad27712a2dfe713e3f63f5c257a60efc9fd8ca001838572d7ca6ff9ccd8 |
Close
Hashes for nonebot_plugin_userinfo-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a018ff1915c0f0ecdb30701d9119e217446f5a0175aebf055e8be29b5e771aa0 |
|
MD5 | f450660dca992ebd50b46002dc6036b8 |
|
BLAKE2b-256 | 7a81e49466aa0a4c53fa731ba56acbcdac7f498dd35bf5cb07b4d897b3c8f6ea |