mirror of
https://github.com/ChenXu233/nonebot_plugin_dialectlist.git
synced 2024-11-30 17:14:45 +08:00
#feature
This commit is contained in:
parent
ffcd7992dd
commit
95c937203d
@ -167,24 +167,26 @@ async def handle_message(
|
|||||||
st = time.time()
|
st = time.time()
|
||||||
|
|
||||||
if isinstance(event,GroupMessageEvent):
|
if isinstance(event,GroupMessageEvent):
|
||||||
bot_id = await bot.call_api('get_login_info')
|
if plugin_config.dialectlist_excluded_self:
|
||||||
bot_id = [str(bot_id['user_id'])]
|
bot_id:str = await bot.call_api('get_login_info')
|
||||||
|
plugin_config.dialectlist_excluded_people.append(bot_id)
|
||||||
gids:List[str] = [str(event.group_id)]
|
gids:List[str] = [str(event.group_id)]
|
||||||
msg_list = await get_message_records(
|
msg_list = await get_message_records(
|
||||||
group_ids=gids,
|
group_ids=gids,
|
||||||
exclude_user_ids=bot_id,
|
exclude_user_ids=plugin_config.dialectlist_excluded_people,
|
||||||
message_type='group',
|
message_type='group',
|
||||||
time_start=start.astimezone(ZoneInfo("UTC")),
|
time_start=start.astimezone(ZoneInfo("UTC")),
|
||||||
time_stop=stop.astimezone(ZoneInfo("UTC"))
|
time_stop=stop.astimezone(ZoneInfo("UTC"))
|
||||||
)
|
)
|
||||||
|
|
||||||
elif isinstance(event, GuildMessageEvent):
|
elif isinstance(event, GuildMessageEvent):
|
||||||
|
if plugin_config.dialectlist_excluded_self:
|
||||||
bot_id = await bot.call_api('get_guild_service_profile')
|
bot_id = await bot.call_api('get_guild_service_profile')
|
||||||
bot_id = [str(bot_id['tiny_id'])]
|
plugin_config.dialectlist_excluded_people.append(bot_id)
|
||||||
guild_ids:List[str] = await get_guild_all_channel(event.guild_id,bot=bot)
|
guild_ids:List[str] = await get_guild_all_channel(event.guild_id,bot=bot)
|
||||||
msg_list = await get_message_records(
|
msg_list = await get_message_records(
|
||||||
group_ids=guild_ids,
|
group_ids=guild_ids,
|
||||||
exclude_user_ids=bot_id,
|
exclude_user_ids=plugin_config.dialectlist_excluded_people,
|
||||||
message_type='group',
|
message_type='group',
|
||||||
time_start=start.astimezone(ZoneInfo("UTC")),
|
time_start=start.astimezone(ZoneInfo("UTC")),
|
||||||
time_stop=stop.astimezone(ZoneInfo("UTC"))
|
time_stop=stop.astimezone(ZoneInfo("UTC"))
|
||||||
@ -199,5 +201,5 @@ async def handle_message(
|
|||||||
|
|
||||||
await rankings.send(msg)
|
await rankings.send(msg)
|
||||||
await asyncio.sleep(1) #让图片先发出来
|
await asyncio.sleep(1) #让图片先发出来
|
||||||
await rankings.finish(plugin_config.dialectlist_string_suffix_format.format(timecost=time.time()-st-1))
|
await rankings.finish(plugin_config.dialectlist_string_suffix_format.format(timeCost=time.time()-st-1))
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
from typing import Optional, Union, Literal
|
from typing import Optional, Literal, List
|
||||||
from nonebot import get_driver
|
from nonebot import get_driver
|
||||||
from pydantic import BaseModel, Extra
|
from pydantic import BaseModel, Extra
|
||||||
|
|
||||||
@ -6,11 +6,14 @@ from pydantic import BaseModel, Extra
|
|||||||
class Config(BaseModel, extra=Extra.ignore):
|
class Config(BaseModel, extra=Extra.ignore):
|
||||||
|
|
||||||
timezone: Optional[str]
|
timezone: Optional[str]
|
||||||
dialectlist_string_format: str = '第{index}名:\n{nickname},{chatdatanum}条消息\n' #消息格式
|
dialectlist_string_format: str = '第{index}名:\n{nickname},{chatDataNum}条消息\n' #消息格式
|
||||||
dialectlist_string_suffix_format: str = '你们的职业是水群吗?————MYX\n计算花费时间:{timecost}秒' #消息后缀格式
|
dialectlist_string_suffix_format: str = '你们的职业是水群吗?————MYX\n计算花费时间:{timeCost}秒' #消息后缀格式
|
||||||
dialectlist_get_num:int = 10 #获取人数数量
|
dialectlist_get_num:int = 10 #获取人数数量
|
||||||
dialectlist_visualization:bool = True #是否可视化
|
dialectlist_visualization:bool = True #是否可视化
|
||||||
dialectlist_visualization_type:Literal['饼图','圆环图','柱状图'] = '圆环图' #可视化方案
|
dialectlist_visualization_type:Literal['饼图','圆环图','柱状图'] = '圆环图' #可视化方案
|
||||||
|
dialectlist_font:str = 'SimHei'#字体格式
|
||||||
|
dialectlist_excluded_people:List[str] = []#排除的人的QQ号(或频道号?(未经测试))
|
||||||
|
dialectlist_excluded_self:bool = True
|
||||||
|
|
||||||
global_config = get_driver().config
|
global_config = get_driver().config
|
||||||
plugin_config = Config.parse_obj(global_config)
|
plugin_config = Config(**global_config.dict())
|
@ -1,4 +1,3 @@
|
|||||||
import time
|
|
||||||
import pygal
|
import pygal
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
@ -7,7 +6,6 @@ from sqlmodel import select, or_
|
|||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
from typing import Iterable, List, Optional, Dict
|
from typing import Iterable, List, Optional, Dict
|
||||||
from pygal.style import Style
|
from pygal.style import Style
|
||||||
style=Style(font_family="SimHei",)
|
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.adapters import Bot
|
from nonebot.adapters import Bot
|
||||||
@ -18,7 +16,7 @@ from nonebot_plugin_datastore import create_session
|
|||||||
from nonebot_plugin_chatrecorder.model import MessageRecord
|
from nonebot_plugin_chatrecorder.model import MessageRecord
|
||||||
|
|
||||||
from .config import plugin_config
|
from .config import plugin_config
|
||||||
|
style=Style(font_family=plugin_config.dialectlist_font)
|
||||||
|
|
||||||
|
|
||||||
def remove_control_characters(string:str) -> str:
|
def remove_control_characters(string:str) -> str:
|
||||||
@ -185,7 +183,7 @@ async def msg_list2msg(
|
|||||||
for i in range(got_num):
|
for i in range(got_num):
|
||||||
index = i+1
|
index = i+1
|
||||||
nickname,chatdatanum = ranking[i]
|
nickname,chatdatanum = ranking[i]
|
||||||
str_example = plugin_config.dialectlist_string_format.format(index=index,nickname=nickname,chatdatanum=chatdatanum)
|
str_example = plugin_config.dialectlist_string_format.format(index=index,nickname=nickname,chatDataNum=chatdatanum)
|
||||||
out = out + str_example
|
out = out + str_example
|
||||||
|
|
||||||
logger.debug(out)
|
logger.debug(out)
|
||||||
|
Loading…
Reference in New Issue
Block a user