-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
53 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import orjson as json | ||
|
||
from core.builtins import Bot | ||
from core.component import module | ||
from core.dirty_check import check | ||
from core.logger import Logger | ||
from core.utils.http import post_url | ||
|
||
n = module("nbnhhsh", | ||
desc="{nbnhhsh.help.desc}", | ||
doc=True, | ||
developers=["Dianliang233"], | ||
support_languages=["zh_cn"] | ||
) | ||
|
||
|
||
@n.command("<term> {{nbnhhsh.help}}") | ||
async def _(msg: Bot.MessageSession, term: str): | ||
res_nbnhhsh = await nbnhhsh(msg, term) | ||
chk = await check(res_nbnhhsh) | ||
res = f"{term.lower()}\n" | ||
for i in chk: | ||
res += i["content"] | ||
await msg.finish(res.strip()) | ||
|
||
|
||
async def nbnhhsh(msg: Bot.MessageSession, term: str): | ||
req = json.dumps({'text': term}) | ||
data = await post_url('https://lab.magiconch.com/api/nbnhhsh/guess', | ||
data=req, | ||
headers={'Content-Type': 'application/json', 'Accept': '*/*', | ||
'Content-Length': str(len(req))}, | ||
fmt='json') | ||
Logger.debug(data) | ||
try: | ||
result = data[0] | ||
except IndexError: | ||
await msg.finish(msg.locale.t("nbnhhsh.message.not_found")) | ||
if 'trans' in result: | ||
trans = result['trans'] | ||
return "、".join(trans) | ||
if 'inputting' in result: | ||
inputting = result['inputting'] | ||
if inputting: | ||
return f'{msg.locale.t("nbnhhsh.message.guess", term=term)}{"、".join(inputting)}' | ||
else: | ||
await msg.finish(msg.locale.t("nbnhhsh.message.not_found")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"nbnhhsh.help.desc": "能不能好好说话?拼音首字母缩写转义工具。", | ||
"nbnhhsh.help": "输入含有首字母缩写的文字获取含义。", | ||
"nbnhhsh.message.guess": "有可能是:", | ||
"nbnhhsh.message.not_found": "没有匹配到拼音首字母缩写。" | ||
} |