Skip to content

Commit

Permalink
新增米游社通过按钮进行选项
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Jan 5, 2024
1 parent 0e3715d commit be8d2e6
Showing 1 changed file with 63 additions and 29 deletions.
92 changes: 63 additions & 29 deletions OlivaStoryCore/msgReply.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import traceback
import json
import uuid

def logProc(Proc:OlivOS.pluginAPI.shallow, level, message, segment):
Proc.log(
Expand Down Expand Up @@ -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':
Expand All @@ -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):
Expand Down

0 comments on commit be8d2e6

Please sign in to comment.