Skip to content

Commit

Permalink
Downgrade nbnhhsh
Browse files Browse the repository at this point in the history
  • Loading branch information
DoroWolf committed Jan 15, 2025
1 parent 7204179 commit 7c9a0c7
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 242 deletions.
2 changes: 0 additions & 2 deletions modules/ask/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from .bugtracker import bugtracker_tool
from .ip_whois import ip_whois_tool
from .mcv import mcv_tool
from .meme import meme_tool
from .random import random_choice_tool, random_number_tool, random_uuid_tool
from .search import search_tool
from .self_knowledge import self_knowledge_tool
Expand All @@ -13,7 +12,6 @@
ip_whois_tool,
mcv_tool,
server_tool,
meme_tool,
random_choice_tool,
random_number_tool,
random_uuid_tool,
Expand Down
19 changes: 0 additions & 19 deletions modules/ask/tools/meme.py

This file was deleted.

61 changes: 38 additions & 23 deletions modules/meme/__init__.py
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"))
34 changes: 0 additions & 34 deletions modules/meme/jiki.py

This file was deleted.

13 changes: 0 additions & 13 deletions modules/meme/locales/en_us.json

This file was deleted.

15 changes: 4 additions & 11 deletions modules/meme/locales/zh_cn.json
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": "没有匹配到拼音首字母缩写。"
}
13 changes: 0 additions & 13 deletions modules/meme/locales/zh_tw.json

This file was deleted.

50 changes: 0 additions & 50 deletions modules/meme/moegirl.py

This file was deleted.

35 changes: 0 additions & 35 deletions modules/meme/nbnhhsh.py

This file was deleted.

42 changes: 0 additions & 42 deletions modules/meme/urban.py

This file was deleted.

0 comments on commit 7c9a0c7

Please sign in to comment.