-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
119 lines (108 loc) · 3.15 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# 首先需要一个能进行回复的机器人框架
import asyncio
from hoshino import Service
from hoshino.modules.priconne import chara
from hoshino.util import filt_message
from zhconv import convert
from . import msg, img as img_
sv = Service('pcr_wiki_bydb', help_='''
[角色]简介
[角色]技能
[角色]动作
[角色]羁绊
[角色]数值
ps:[]内填写的是角色名称/别称
'''.strip(), bundle='pcr_wiki')
async def get_chara_uid(name, bot, ev):
uid = chara.name2id(name)
confi = 100
guess = False
if uid == chara.UNKNOWN:
uid, guess_name, confi = chara.guess_id(name)
guess = True
c = chara.fromid(uid)
if confi < 60:
return -1
if guess:
name = filt_message(name)
msg = f'兰德索尔似乎没有叫"{name}"的人...\n角色别称补全计划: github.com/Ice9Coffee/LandosolRoster'
await bot.send(ev, msg)
msg = f'您有{confi}%的可能在找{guess_name} {await c.get_icon_cqcode()} {c.name}'
await bot.send(ev, msg)
return -1
else:
# unit_id是整形,查找需要末尾加01
return uid * 100 + 1, c
@sv.on_suffix('简介')
async def chara_intro(bot, ev):
name = ev.message.extract_plain_text().strip()
if not name:
return
uid, c = await get_chara_uid(name, bot, ev)
if uid == -1:
return
# 创建查找对象列表
search_list = [
'name',
'talent',
'guild',
'brithday',
'age',
'height',
'weight',
'bloodtype',
'race',
'favorite',
'cv',
'description']
# 开始查找
result = ''
result += f'{c.icon.cqcode}'
result += msg.msg_process(uid, search_list)
await bot.send(ev, result)
@sv.on_suffix('技能')
async def chara_intro(bot, ev):
name = ev.message.extract_plain_text().strip()
if not name:
return
uid, c = await get_chara_uid(name, bot, ev)
if uid == -1:
return
# 创建查找对象列表
search_list = [
'name',
'skill_ub',
'skill_ms',
'skill_ex',
'skill_sp'
]
# 开始查找
result = ''
result += f'{c.icon.cqcode}'
result_img = msg.msg_process(uid, search_list)
beg = 0
while result_img.find('img', beg) != -1:
index = result_img.find('img', beg)
icon_id = result_img[index+4:index+8]
img = result_img[index:index+8]
result_img = result_img.replace(img, img_.resize_icon(icon_id))
beg = index + 10
result += result_img
await bot.send(ev, result)
@sv.on_suffix('循环')
async def chara_intro(bot, ev):
name = ev.message.extract_plain_text().strip()
if not name:
return
uid, c = await get_chara_uid(name, bot, ev)
if uid == -1:
return
# 创建查找对象列表
search_list = [
'name'
]
# 开始查找
result = ''
result += f'{c.icon.cqcode}'
result += msg.msg_process(uid, search_list)
await bot.send(ev, result)