-
Notifications
You must be signed in to change notification settings - Fork 2
3.1 MessageSegment
17TheWord edited this page Mar 17, 2024
·
9 revisions
-
关于
model
内的WebSocket Component
组件,即通过WebSocket发送消息 -
Hover
仍有部分未实现(欢迎PR
插件或mod)
from nonebot.adapters.minecraft import MessageSegment
from nonebot.adapters.minecraft.model import (
TextColor,
ClickEvent,
HoverEvent,
ClickAction,
HoverAction,
BaseComponent
)
click_event = ClickEvent()
click_event.action = ClickAction.OPEN_URL
click_event.value = "https://www.baidu.com"
base_component = BaseComponent(
text="BaseComponent",
color=TextColor.RED,
bold=True,
italic=True,
underlined=True,
strikethrough=True,
obfuscated=True,
insertion="test"
)
hover_event = HoverEvent()
hover_event.action = HoverAction.SHOW_TEXT
hover_event.base_component_list = [base_component]
MessageSegment.text(
text="test",
color=TextColor.RED,
bold=True,
italic=True,
underlined=True,
strikethrough=True,
obfuscated=True,
insertion="test",
click_event=click_event,
hover_event=hover_event
)
from nonebot.adapters.minecraft import MessageSegment
MessageSegment.title(
title="title",
subtitle="subtitle",
fadein=10,
stay=70,
fadeout=20
)
from nonebot.adapters.minecraft import MessageSegment
MessageSegment.actionbar(
text="test",
color=TextColor.RED,
bold=True,
italic=True,
underlined=True,
strikethrough=True,
obfuscated=True,
insertion="test"
)
from nonebot.adapters.minecraft import MessageSegment
MessageSegment.chat_image_mod(
url="https://xxxx.com/xxx.png",
name="图片",
color=TextColor.RED,
bold=True,
italic=True,
underlined=True,
strikethrough=True,
obfuscated=True,
insertion="test"
)