mirror of
https://github.com/ChenXu233/nonebot_plugin_dialectlist.git
synced 2024-11-25 00:25:28 +08:00
Compare commits
4 Commits
4e339bcdb1
...
07f85be527
Author | SHA1 | Date | |
---|---|---|---|
|
07f85be527 | ||
|
f2cdfe7f8a | ||
|
e0ca7907c0 | ||
|
53b2a33923 |
19
README.md
19
README.md
@ -77,6 +77,8 @@ __!!注意!!__
|
||||
|
||||
### 🎨一般用法
|
||||
|
||||
#### B话榜
|
||||
|
||||
-`/B话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
|
||||
|
||||
-`/今日B话榜` ————看看今天的群友发了多少消息!
|
||||
@ -95,8 +97,14 @@ __!!注意!!__
|
||||
|
||||
-`/历史B话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
|
||||
|
||||
#### 看看B话(kkb)
|
||||
|
||||
-`/看看B话 [@某人|QQ号]` ————看看这个b人在这个b群发了多少b话!
|
||||
|
||||
### 🚀进阶用法
|
||||
|
||||
#### B话榜
|
||||
|
||||
`/{时间类型(今日|年度)?}{B话榜|废话榜} {时间类型?} {ISO8601 格式时间 ?} {群号} {关键词}`
|
||||
|
||||
如:`/B话榜 历史 2024-01-01~2024-01-02 12345678 女装`
|
||||
@ -109,6 +117,15 @@ __!!注意!!__
|
||||
`/昨日B话榜 -k 女装`
|
||||
`/本周B话榜 -g 12345678`
|
||||
|
||||
#### 看看B话
|
||||
|
||||
`/看看B话 {@|QQ号} {群号?} {关键词?}`
|
||||
|
||||
以下调用方法均合法:
|
||||
|
||||
`/kkb 114514 1919810 ♂`
|
||||
`/kkb @man -k ♂`
|
||||
|
||||
## 💪 目前支持的平台
|
||||
|
||||
| 平台 | 是否经过测试 | 是否能够正常工作 | 测试环境 |
|
||||
@ -174,7 +191,7 @@ __!!注意!!__
|
||||
|
||||
- [x] 查询带某关键词的消息量
|
||||
|
||||
- [ ] 合并转发
|
||||
- [x] 合并转发
|
||||
|
||||
待补充。.....
|
||||
|
||||
|
@ -23,7 +23,10 @@ from nonebot.params import Arg, Depends
|
||||
from nonebot.adapters import Bot, Event
|
||||
from nonebot.plugin import PluginMetadata, inherit_supported_adapters
|
||||
from nonebot_plugin_alconna import (
|
||||
At,
|
||||
Args,
|
||||
Field,
|
||||
Match,
|
||||
Option,
|
||||
Alconna,
|
||||
on_alconna,
|
||||
@ -85,6 +88,55 @@ async def _build_cache(bot: Bot, event: Event):
|
||||
await saa.Text("重建缓存完成。").send(reply=True)
|
||||
|
||||
|
||||
b_cmd = on_alconna(
|
||||
Alconna(
|
||||
"看看B话",
|
||||
Args["at", [str, At], Field(completion=lambda: "请想要查询的人的QQ号")],
|
||||
Option("-g|--group_id", Args["group_id?", str]),
|
||||
Option("-k|--keyword", Args["keyword?", str])
|
||||
),
|
||||
aliases={"kkb"},
|
||||
use_cmd_start=True,
|
||||
)
|
||||
|
||||
@b_cmd.handle()
|
||||
async def handle_b_cmd(
|
||||
at:Match[str|At],
|
||||
group_id: Match[str],
|
||||
keyword: Match[str],
|
||||
session: Session = Depends(extract_session),
|
||||
):
|
||||
id = at.result
|
||||
if isinstance(id, At):
|
||||
id = id.target
|
||||
if group_id.available:
|
||||
gid = group_id.result
|
||||
else:
|
||||
gid = session.id2
|
||||
|
||||
if not gid:
|
||||
await b_cmd.finish("请指定群号。")
|
||||
|
||||
if keyword.available:
|
||||
keywords = keyword.result
|
||||
else:
|
||||
keywords = None
|
||||
|
||||
messages = await get_message_records(
|
||||
id1s=[id],
|
||||
id2s=[gid],
|
||||
id_type=SessionIdType.GROUP,
|
||||
include_bot_id=False,
|
||||
include_bot_type=False,
|
||||
types=["message"], # 排除机器人自己发的消息
|
||||
exclude_id1s=plugin_config.excluded_people,
|
||||
)
|
||||
d = msg_counter(messages, keywords)
|
||||
rank = got_rank(d)
|
||||
|
||||
await saa.Text(f"该用户在群{gid}的B话数量为{rank[0][1]}。").send(reply=True)
|
||||
|
||||
|
||||
rank_cmd = on_alconna(
|
||||
Alconna(
|
||||
"B话榜",
|
||||
@ -267,7 +319,7 @@ async def handle_rank(
|
||||
t1 = t.time()
|
||||
rank2 = await get_user_infos(bot, event, rank)
|
||||
logger.debug(f"获取用户信息花费时间:{t.time() - t1}")
|
||||
|
||||
|
||||
string: str = ""
|
||||
if plugin_config.show_text_rank:
|
||||
|
||||
@ -275,7 +327,7 @@ async def handle_rank(
|
||||
string += f"关于{keyword}的话痨榜结果:\n"
|
||||
else:
|
||||
string += "话痨榜:\n"
|
||||
|
||||
|
||||
for i in rank2:
|
||||
logger.debug(i.user_name)
|
||||
for i in range(len(rank2)):
|
||||
@ -300,5 +352,8 @@ async def handle_rank(
|
||||
msg += suffix
|
||||
if not msg:
|
||||
await saa.Text("你把可视化都关了哪来的排行榜?").finish()
|
||||
|
||||
await msg.finish(reply=True)
|
||||
|
||||
if plugin_config.aggregate_transmission:
|
||||
await saa.AggregatedMessageFactory([msg]).finish(reply=True)
|
||||
else:
|
||||
await msg.finish(reply=True)
|
||||
|
@ -9,10 +9,11 @@ class ScopedConfig(BaseModel):
|
||||
suffix: bool = True # 是否显示后缀
|
||||
excluded_self: bool = True # 是否排除自己
|
||||
visualization: bool = True # 是否可视化
|
||||
show_text_rank:bool = True # 是否显示文本排名
|
||||
show_text_rank: bool = True # 是否显示文本排名
|
||||
counting_cache: bool = False # 计数缓存(能够提高回复速度)
|
||||
excluded_people: List[str] = [] # 排除的人的QQ号
|
||||
use_user_info_cache: bool = False # 是否使用用户信息缓存
|
||||
aggregate_transmission:bool = False # 是否聚合转发消息
|
||||
timezone: Optional[str] = "Asia/Shanghai" # 时区,影响统计时间
|
||||
string_suffix: str = "统计花费时间:{timecost}秒" # 消息格式后缀
|
||||
template_path: str = "./template/rank_template.j2" # 模板路径
|
||||
|
@ -7,6 +7,8 @@ __usage__ = cleandoc(
|
||||
|
||||
### 🎨一般用法
|
||||
|
||||
#### B话榜
|
||||
|
||||
-`/B话榜` ————看看有史以来(机器人存在以来)群友们发了多少消息! (好像没写)
|
||||
|
||||
-`/今日B话榜` ————看看今天的群友发了多少消息!
|
||||
@ -25,8 +27,14 @@ __usage__ = cleandoc(
|
||||
|
||||
-`/历史B话榜` ————看看历史上(机器人存在以来)的群友发了多少消息!
|
||||
|
||||
#### 看看B话(kkb)
|
||||
|
||||
-`/看看B话 [@某人|QQ号]` ————看看这个b人在这个b群发了多少b话!
|
||||
|
||||
### 🚀进阶用法
|
||||
|
||||
#### B话榜
|
||||
|
||||
`/{时间类型(今日|年度)?}{B话榜|废话榜} {时间类型?} {ISO8601 格式时间 ?} {群号} {关键词}`
|
||||
|
||||
如:`/B话榜 历史 2024-01-01~2024-01-02 12345678 女装`
|
||||
@ -39,5 +47,14 @@ __usage__ = cleandoc(
|
||||
`/昨日B话榜 -k 女装`
|
||||
`/本周B话榜 -g 12345678`
|
||||
|
||||
#### 看看B话
|
||||
|
||||
`/看看B话 {@|QQ号} {群号?} {关键词?}`
|
||||
|
||||
以下调用方法均合法:
|
||||
|
||||
`/kkb 114514 1919810 ♂`
|
||||
`/kkb @man -k ♂`
|
||||
|
||||
"""
|
||||
)
|
||||
|
@ -94,7 +94,7 @@ def msg_counter(
|
||||
logger.info("wow , there are {} msgs to count !!!".format(msg_len))
|
||||
|
||||
for i in msg_list:
|
||||
logger.debug(f"processing msg {i.plain_text}")
|
||||
# logger.debug(f"processing msg {i.plain_text}")
|
||||
if keyword:
|
||||
if keyword not in i.plain_text:
|
||||
continue
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "nonebot-plugin-dialectlist"
|
||||
version = "2.4.6"
|
||||
version = "2.5.1"
|
||||
description = "看看你群群友有多能说"
|
||||
authors = [
|
||||
{name = "Chen_Xu233", email = "woyerpa@outlook.com"},
|
||||
|
Loading…
Reference in New Issue
Block a user