-
Notifications
You must be signed in to change notification settings - Fork 7
/
chara.py
45 lines (36 loc) · 1001 Bytes
/
chara.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
import json
import os
from os.path import join
from hoshino import logger
CONFIG_PATH = os.path.dirname(__file__)
with open(join(CONFIG_PATH, 'characters.json'), 'r', encoding='UTF-8') as f:
characters = json.load(f)
with open(join(CONFIG_PATH, 'charaname.json'), 'r', encoding='UTF-8') as f:
charaname = json.load(f)
async def check_chara(name: str):
try:
for i in charaname:
if name in i:
return i[0]
return None
except Exception as e:
logger.error(e)
return None
async def check_name(name: str):
try:
for i in characters:
if i["name"] == name:
return i
return None
except Exception as e:
logger.error(e)
return None
async def all_chara(name: str):
try:
for i in charaname:
if name in i:
return [i[0], ",".join(i)]
return None
except Exception as e:
logger.error(e)
return None