-
Notifications
You must be signed in to change notification settings - Fork 0
/
otto.py
48 lines (36 loc) · 1.42 KB
/
otto.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
import os
import re
from nonebot import MessageSegment
import hoshino
from hoshino import Service,priv
from .HuoZiYinShua.huoZiYinShua import huoZiYinShua
self_path = os.path.dirname(__file__)
settings = {
"sourceDirectory": os.path.join(self_path, 'HuoZiYinShua', 'sources',''),
"ysddSourceDirectory": os.path.join(self_path, 'HuoZiYinShua', 'ysddSources',''),
"dictFile": os.path.join(self_path, 'HuoZiYinShua', 'dictionary.json'),
"ysddTableFile": os.path.join(self_path, 'HuoZiYinShua', 'ysddTable.json')
}
HZYS = huoZiYinShua(settings)
sv = Service(
name = 'ottohzys', #功能名
use_priv = priv.NORMAL, #使用权限
manage_priv = priv.ADMIN, #管理权限
visible = True, #False隐藏
enable_on_default = True, #是否默认启用
)
# self_path = os.path.dirname(__file__)
@sv.on_prefix("otto",only_to_me=False)
async def ottohzys(bot, ev):
txt = ev.message.extract_plain_text()
pattern_reverse = re.compile(u'-reverse\s*$')
if isinstance(re.search(pattern_reverse, txt), (re.Match)):
# 结尾匹配到 -reverse
reverse = True
txt = re.sub(pattern_reverse, "", txt)
txt = ",,," + txt # 加一段空白
else:
reverse = False
txt = txt + ",,," # 加一段空白
b64audio = HZYS.export(txt,inYsddMode=True,reverse=reverse)
await bot.send(ev, MessageSegment.record(f"base64://{b64audio.decode()}"))