From be8d2e686469d2317520c5f8baa88f6a09094df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Fri, 5 Jan 2024 11:29:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=B1=B3=E6=B8=B8=E7=A4=BE?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E6=8C=89=E9=92=AE=E8=BF=9B=E8=A1=8C=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OlivaStoryCore/msgReply.py | 92 ++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 29 deletions(-) diff --git a/OlivaStoryCore/msgReply.py b/OlivaStoryCore/msgReply.py index 064c3ba..8400257 100644 --- a/OlivaStoryCore/msgReply.py +++ b/OlivaStoryCore/msgReply.py @@ -20,6 +20,7 @@ import traceback import json +import uuid def logProc(Proc:OlivOS.pluginAPI.shallow, level, message, segment): Proc.log( @@ -444,41 +445,39 @@ def getStoryTall( and tmp_model not in ['text']: try: if plugin_event.indeAPI.hasAPI('create_message'): - msg_button_list = [ - { - "type": "action-group", - "elements": [ - { - "type": "button", - "theme": "info", - "value": f'{selection_str[0]}', - "click": "return-val", - "text": { - "type": "plain-text", - "content": f'{selection_str[1]}' - } - } - ] - } for selection_str in selection_str_list - ] - msg_button_list.append( - { - "type": "context", - "elements": [ - { - "type": "plain-text", - "content": "OlivaDice - 青果核心掷骰机器人" - } - ] - } - ) msg_list = [ { "type": "card", "theme": "primary", "color": "#009FE9", "size": "lg", - "modules": msg_button_list + "modules": [ + { + "type": "action-group", + "elements": [ + { + "type": "button", + "theme": "info", + "value": f'{selection_str[0]}', + "click": "return-val", + "text": { + "type": "plain-text", + "content": f'{selection_str[1]}' + } + } + ] + } for selection_str in selection_str_list + ] + [ + { + "type": "context", + "elements": [ + { + "type": "plain-text", + "content": "OlivaDice - 青果核心掷骰机器人" + } + ] + } + ] } ] if plugin_event.plugin_info['func_type'] == 'group_message': @@ -497,6 +496,41 @@ def getStoryTall( ) except Exception as e: traceback.print_exc() + + elif tmp_platform == 'mhyVila': + try: + if plugin_event.indeAPI.hasAPI('create_message'): + msg_list = { + "content": { + "text": "选项如下:" + }, + "panel": { + "big_component_group_list": [ + [ + { + "id": str(uuid.uuid4()), + "text": f'{selection_str[1][:9]}...' if len(selection_str[1]) > 12 else f'{selection_str[1]}', + "type": 1, + "extra": f'{selection_str[0]}', + "need_callback": False, + "c_type": 2, + "input": f'{selection_str[0]}', + "link": "" + } + ] for selection_str in selection_str_list + ] + } + } + if plugin_event.plugin_info['func_type'] == 'group_message': + plugin_event.indeAPI.create_message( + chat_type = 'group', + chat_id = plugin_event.data.group_id, + object_name = 'MHY:Text', + content = msg_list, + host_id = plugin_event.data.host_id + ) + except Exception as e: + traceback.print_exc() return res def getStorySearchList(storyName_search:str, botHash:str):