Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/meme/nbnhhsh.py

31 lines
1,018 B
Python
Raw Normal View History

import traceback
2022-01-03 09:13:42 +00:00
import ujson as json
from core.utils import post_url
async def nbnhhsh(term: str):
'''查询nbnhhsh。
:param term: 需要查询的term
:returns: 查询结果'''
try:
url = 'https://lab.magiconch.com/api/nbnhhsh/guess' + term
text = await post_url(url, data={'text': term})
print(text)
2022-01-03 09:13:42 +00:00
data = json.loads(text)['data']
result = data[0]
if 'trans' in result:
trans = result['trans']
count = trans.__len__()
return f'[nbnhhsh]{count}个结果,已收录):{"".join(trans)}'
elif 'inputting' in result and result['inputting'] != []:
inputting = result['inputting']
count = inputting.__len__()
return f'[nbnhhsh]{count}个结果AI 猜测):{"".join(inputting)}'
else:
return '[nbnhhsh] 没有找到相关结果。'
except Exception:
traceback.print_exc()
2022-01-03 09:13:42 +00:00
return '[nbnhhsh] 查询出错。'