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/dictionary/__init__.py
2022-07-31 16:33:20 +08:00

23 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from core.builtins.message import MessageSession
from core.component import on_command
from core.elements import Image, Plain
from .screenshot import get_pic
dict_module = on_command('dictionary', alias=["dict"],
desc='查询科林斯词典。', developers=['Dianliang233'])
@dict_module.handle(help_doc='<term> {在科林斯词典中查询单词,暂仅支持英文}')
async def _(msg: MessageSession):
print(str(msg.parsed_msg['<term>']).replace(' ', '-').lower())
pic_collins = await get_pic(
'https://www.collinsdictionary.com/dictionary/english/' + str(msg.parsed_msg['<term>']).replace(' ',
'-').lower(),
'collins')
# pic_yd = await get_pic('https://www.youdao.com/result?word=' + msg.parsed_msg['<term>'] + '&lang=en', 'yd')
# if pic_collins or pic_yd:
if pic_collins:
# await msg.finish([Image(pic_collins), Image(pic_yd),
await msg.finish([Image(pic_collins), Plain(
f'https://www.collinsdictionary.com/dictionary/english/{msg.parsed_msg["<term>"]}')])
# 有道https://www.youdao.com/result?lang=en&word={msg.parsed_msg["<term>"]}'''])