Archived
1
0
Fork 0
This commit is contained in:
yzhh 2024-02-24 16:50:42 +08:00
parent 32ea202c75
commit 35e9de7abc
2 changed files with 25 additions and 21 deletions

View file

@ -4,6 +4,7 @@ from typing import List, Union, Dict, Coroutine, Awaitable
from core.exceptions import FinishedException
from .chain import MessageChain
from .internal import Plain, Image, Voice, Embed, Url, ErrorMessage
class MsgInfo:
@ -30,8 +31,8 @@ class MsgInfo:
def __repr__(self):
return f'MsgInfo(target_id={self.target_id}, sender_id={self.sender_id}, sender_name={self.sender_name},' \
f' target_from={self.target_from}, sender_from={self.sender_from}, client_name={self.client_name}, ' \
f'message_id={self.message_id}, reply_id={self.reply_id})'
f' target_from={self.target_from}, sender_from={self.sender_from}, client_name={self.client_name}, ' \
f'message_id={self.message_id}, reply_id={self.reply_id})'
class Session:
@ -87,7 +88,7 @@ class MessageSession:
self.tmp = {}
async def send_message(self,
message_chain: MessageChain,
message_chain: Union[MessageChain, str, Plain, Image, Voice, Embed, Url, ErrorMessage],
quote=True,
disable_secret_check=False,
allow_split_image=True,
@ -104,7 +105,7 @@ class MessageSession:
raise NotImplementedError
async def finish(self,
message_chain: MessageChain = None,
message_chain: Union[MessageChain, str, Plain, Image, Voice, Embed, Url, ErrorMessage] = None,
quote: bool = True,
disable_secret_check: bool = False,
allow_split_image: bool = True,

View file

@ -150,25 +150,28 @@ async def _(msg: Bot.MessageSession):
await msg.send_message(Image(get_infobox), quote=False)
if get_page.invalid_section and wiki_.wiki_info.in_allowlist and web_render:
i_msg_lst = []
session_data = [[str(i + 1), get_page.sections[i]] for i in
range(len(get_page.sections))]
i_msg_lst.append(Plain(msg.locale.t('wiki.message.invalid_section')))
i_msg_lst.append(Image(await
image_table_render(
ImageTable(session_data,
['ID',
msg.locale.t('wiki.message.section')]))))
if get_page.sections:
session_data = [[str(i + 1), get_page.sections[i]] for i in
range(len(get_page.sections))]
i_msg_lst.append(Plain(msg.locale.t('wiki.message.invalid_section')))
i_msg_lst.append(Image(await
image_table_render(
ImageTable(session_data,
['ID',
msg.locale.t('wiki.message.section')]))))
async def _callback(msg: Bot.MessageSession):
display = msg.as_display(text_only=True)
if display.isdigit():
display = int(display)
if display <= len(get_page.sections):
get_page.selected_section = display - 1
await query_pages(msg, title=get_page.title + '#' +
get_page.sections[display - 1])
async def _callback(msg: Bot.MessageSession):
display = msg.as_display(text_only=True)
if display.isdigit():
display = int(display)
if display <= len(get_page.sections):
get_page.selected_section = display - 1
await query_pages(msg, title=get_page.title + '#' +
get_page.sections[display - 1])
await msg.send_message(i_msg_lst, callback=_callback)
await msg.send_message(i_msg_lst, callback=_callback)
else:
await msg.send_message(Plain(msg.locale.t('wiki.message.invalid_section.prompt')))
if len(query_list) == 1 and img_send:
return
if msg.Feature.image: