🐛 修复空白qq头像导致的问题

This commit is contained in:
CMHopeSunshine 2022-09-06 11:17:39 +08:00
parent 39f65a3258
commit 4ec9af1bb8
5 changed files with 18 additions and 63 deletions

View File

@ -71,7 +71,7 @@ async def _(event: PrivateMessageEvent, state: T_State, match: dict = RegexDict(
@manage_cmd.got('bool')
async def _(state: T_State):
if not state['group'] and state['user']:
await manage_cmd.finish('使用ban|unban -g 群号 -u 用户', at_sender=True)
await manage_cmd.finish('法:ban|unban 插件名 -g 群号列表 -u 用户列表', at_sender=True)
if state['session_id'] in cache_help:
del cache_help[state['session_id']]
if not state['plugin'] and state['plugin_no_exist']:

View File

@ -17,11 +17,14 @@ small_avatar_cache = {}
async def get_avatar(qid: str, size: Tuple[int, int] = (146, 146)) -> PMImage:
try:
avatar = await get_qq_avatar(qid)
await avatar.resize(size)
await avatar.to_circle('circle')
await avatar.add_border(6, '#ddcdba', 'circle')
return avatar
except Exception:
return PMImage(size=size, color=(255, 255, 255, 255))
async def small_avatar(info: FiveStarItem):

View File

@ -25,11 +25,14 @@ def get_percent_text(percent: int) -> str:
async def get_avatar(qid: str, size: Tuple[int, int] = (146, 146)) -> PMImage:
try:
avatar = await get_qq_avatar(qid)
await avatar.resize(size)
await avatar.to_circle('circle')
await avatar.add_border(6, '#ddcdba', 'circle')
return avatar
except Exception:
return PMImage(size=size, color=(255, 255, 255, 255))
async def draw_weapon_icon(weapon: Weapon, size: Tuple[int, int] = (65, 65)) -> PMImage:

View File

@ -117,7 +117,7 @@ def load_yaml(path: Union[Path, str], encoding: str = 'utf-8'):
if isinstance(path, str):
path = Path(path)
return yaml.load(path.open('r', encoding=encoding),
Loader=yaml.RoundTripLoader) if path.exists() else yaml.round_trip_load('{}')
Loader=yaml.Loader) if path.exists() else yaml.round_trip_load('{}')
def save_yaml(data: dict, path: Union[Path, str] = None, encoding: str = 'utf-8'):

View File

@ -1,51 +0,0 @@
from nonebot import on_command
from nonebot.plugin import PluginMetadata
"""
一个插件配置例子不是最终版本可能会有更多的变动
"""
__plugin_meta__ = PluginMetadata(
name='test plugin',
description='a test plugin',
usage='only test',
extra={
'author': '惜月',
'type': '其他',
'default_status': True,
'priority': 1,
'permit_range': ['private', 'group', 'guild'],
'permit_member': ['superuser', 'admin', 'member'],
'configs': {
'config1': {
'description': 'config1 description',
'value': 1
},
'config2': {
'description': 'config2 description',
'value': 123
}
},
}
)
command = on_command('example', priority=1, block=True)
command.__paimon_meta__ = {
'name': 'test command',
'description': 'a test command',
'usage': 'only test',
'default_status': True,
'priority': 1,
'cooldown': {
'per_user': 1,
'per_private_user': 1,
'per_group': 1,
'per_group_member': 2,
'per_guild': 5,
'per_guild_channel': 6,
'per_guild_member': 7
},
'permit_range': ['private', 'group', 'guild'],
'permit_member': ['superuser', 'admin', 'member']
}