-
-
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
10 changed files
with
42 additions
and
242 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 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 |
---|---|---|
@@ -1,32 +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 | ||
|
||
# from modules.meme.jiki import jiki | ||
from modules.meme.moegirl import moegirl | ||
from modules.meme.nbnhhsh import nbnhhsh | ||
from modules.meme.urban import urban | ||
|
||
meme = module( | ||
bind_prefix="meme", | ||
# well, people still use it though it only lived for an hour or so | ||
alias="nbnhhsh", | ||
desc="{meme.help.desc}", | ||
doc=True, | ||
developers=["Dianliang233"], | ||
support_languages=["zh_cn", "en_us"], | ||
) | ||
n = module("nbnhhsh", | ||
desc="{nbnhhsh.help.desc}", | ||
doc=True, | ||
developers=["Dianliang233"], | ||
support_languages=["zh_cn"] | ||
) | ||
|
||
|
||
@meme.command("<term> {{meme.help}}") | ||
@n.command("<term> {{nbnhhsh.help}}") | ||
async def _(msg: Bot.MessageSession, term: str): | ||
# res_jiki = await jiki(msg.parsed_msg['<term>'], msg.locale) | ||
# R.I.P. jikipedia | ||
res_moegirl = await moegirl(term, msg.locale) | ||
res_nbnhhsh = await nbnhhsh(term, msg.locale) | ||
res_urban = await urban(term, msg.locale) | ||
chk = await check(res_moegirl, res_nbnhhsh, res_urban) | ||
res = "" | ||
res_nbnhhsh = await nbnhhsh(msg, term) | ||
chk = await check(res_nbnhhsh) | ||
res = f"{term.lower()}\n" | ||
for i in chk: | ||
res += i["content"] + "\n" | ||
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 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 |
---|---|---|
@@ -1,13 +1,6 @@ | ||
{ | ||
"meme.help": "在萌娘百科、nbnhhsh、Urban Dictionary 等中查询迷因。", | ||
"meme.help.desc": "全功能迷因查询。", | ||
"meme.message.error": "查询出错。", | ||
"meme.message.jiki": "小鸡百科", | ||
"meme.message.moegirl": "萌娘百科", | ||
"meme.message.nbnhhsh": "nbnhhsh", | ||
"meme.message.nbnhhsh.result": "(${result} 个结果,已收录):", | ||
"meme.message.nbnhhsh.result.ai": "(${result} 个结果,AI 猜测):", | ||
"meme.message.not_found": "没有找到相关结果。", | ||
"meme.message.result": "(${result} 个结果):", | ||
"meme.message.urban": "Urban Dictionary" | ||
"nbnhhsh.help.desc": "能不能好好说话?拼音首字母缩写转义工具。", | ||
"nbnhhsh.help": "输入含有首字母缩写的文字获取含义。", | ||
"nbnhhsh.message.guess": "有可能是:", | ||
"nbnhhsh.message.not_found": "没有匹配到拼音首字母缩写。" | ||
} |
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.