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

22 lines
1 KiB
Python
Raw Normal View History

2023-02-05 14:33:33 +00:00
from core.builtins import Bot, Image, Plain
2023-03-04 08:51:56 +00:00
from core.component import module
2022-07-26 12:25:18 +00:00
from .screenshot import get_pic
2023-06-01 17:08:10 +00:00
dict_module = module('dictionary', alias="dict",
2023-04-30 03:30:59 +00:00
desc='{dictionary.help.desc}', developers=['Dianliang233'], support_languages=['en_us'])
2022-07-26 12:25:18 +00:00
2023-04-16 01:18:57 +00:00
@dict_module.handle(help_doc='<term> {{dictionary.help}}')
2023-06-04 13:03:24 +00:00
async def _(msg: Bot.MessageSession, term: str):
2022-07-31 08:33:20 +00:00
pic_collins = await get_pic(
2023-06-04 13:03:24 +00:00
'https://www.collinsdictionary.com/dictionary/english/' + str(term).replace(' ',
'-').lower(),
2022-07-31 08:33:20 +00:00
'collins')
2022-07-26 12:25:18 +00:00
# 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),
2022-07-26 12:54:57 +00:00
await msg.finish([Image(pic_collins), Plain(
2023-06-04 13:03:24 +00:00
f'https://www.collinsdictionary.com/dictionary/english/{term}')])
2022-07-26 12:25:18 +00:00
# 有道https://www.youdao.com/result?lang=en&word={msg.parsed_msg["<term>"]}'''])