Class MiraiStrangerMessagePreSendEvent

java.lang.Object
org.spongepowered.api.event.impl.AbstractEvent
me.dreamvoid.miraimc.sponge.event.message.presend.MiraiStrangerMessagePreSendEvent
All Implemented Interfaces:
org.spongepowered.api.event.Cancellable, org.spongepowered.api.event.Event

public class MiraiStrangerMessagePreSendEvent extends org.spongepowered.api.event.impl.AbstractEvent
(Sponge) 消息 - 主动发送消息前 - 陌生人消息
  • Field Summary

    Fields inherited from class org.spongepowered.api.event.impl.AbstractEvent

    currentOrder
  • Constructor Summary

    Constructors
    Constructor
    Description
    MiraiStrangerMessagePreSendEvent(net.mamoe.mirai.event.events.StrangerMessagePreSendEvent event, org.spongepowered.api.event.Cause cause)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull org.spongepowered.api.event.Cause
     
    long
    返回发送这条信息的机器人ID
    返回接收者的备注名
    返回接收到的消息内容转换到字符串的结果
    此方法使用 contentToString()
    QQ 对话框中以纯文本方式会显示的消息内容,这适用于MC与QQ的消息互通等不方便展示原始内容的场景。
    Deprecated. 
    返回接收到的消息内容
    此方法使用 toString()
    Java 对象的 toString(),会尽可能包含多的信息用于调试作用,行为可能不确定
    如需处理常规消息内容,请使用 getMessageContent()
    long
    返回接收者ID
    返回接收这条信息的目标昵称
    boolean
    消息是否已被取消发送
    void
    setCancelled(boolean cancel)
    取消消息的发送
    请注意,无论 cancel 参数设为什么,只要被取消过,就不能撤销。
    void
    setMessage(String message)
    设置将要发送的消息内容 支持 Mirai Code
    获取原始事件内容
    [!]

    Methods inherited from class org.spongepowered.api.event.impl.AbstractEvent

    init

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.spongepowered.api.event.Event

    context, source
  • Constructor Details

    • MiraiStrangerMessagePreSendEvent

      public MiraiStrangerMessagePreSendEvent(net.mamoe.mirai.event.events.StrangerMessagePreSendEvent event, org.spongepowered.api.event.Cause cause)
  • Method Details

    • getTargetNick

      public String getTargetNick()
      返回接收这条信息的目标昵称
      Returns:
      目标昵称
    • getFriendRemark

      public String getFriendRemark()
      返回接收者的备注名
      Returns:
      备注名
    • getBotID

      public long getBotID()
      返回发送这条信息的机器人ID
      Returns:
      机器人ID
    • getTargetID

      public long getTargetID()
      返回接收者ID
      Returns:
      可以是QQ号或群号
    • getMessage

      public String getMessage()
      返回接收到的消息内容转换到字符串的结果
      此方法使用 contentToString()
      QQ 对话框中以纯文本方式会显示的消息内容,这适用于MC与QQ的消息互通等不方便展示原始内容的场景。
      无法用纯文字表示的消息会丢失信息,如任何图片都是 [图片]
      Returns:
      转换字符串后的消息内容
    • getMessageContent

      @Deprecated public String getMessageContent()
      Deprecated.
      返回接收到的消息内容转换到字符串的结果
      此方法使用 contentToString()
      QQ 对话框中以纯文本方式会显示的消息内容,这适用于MC与QQ的消息互通等不方便展示原始内容的场景。
      无法用纯文字表示的消息会丢失信息,如任何图片都是 [图片]
      Returns:
      转换字符串后的消息内容
      See Also:
    • getMessageToString

      public String getMessageToString()
      返回接收到的消息内容
      此方法使用 toString()
      Java 对象的 toString(),会尽可能包含多的信息用于调试作用,行为可能不确定
      如需处理常规消息内容,请使用 getMessageContent()
      Returns:
      原始消息内容
    • setMessage

      public void setMessage(String message)
      设置将要发送的消息内容 支持 Mirai Code
      Parameters:
      message - 带 Mirai Code 的消息
    • isCancelled

      public boolean isCancelled()
      消息是否已被取消发送
      Specified by:
      isCancelled in interface org.spongepowered.api.event.Cancellable
      Returns:
      如果消息被取消发送,返回true
    • setCancelled

      public void setCancelled(boolean cancel)
      取消消息的发送
      请注意,无论 cancel 参数设为什么,只要被取消过,就不能撤销。
      也就是说,已取消的事件永远不会继续发送消息。
      Specified by:
      setCancelled in interface org.spongepowered.api.event.Cancellable
      Parameters:
      cancel - 调用此方法将忽略本参数,无论设为什么
    • toString

      public String toString()
      获取原始事件内容
      [!] 不推荐使用
      Overrides:
      toString in class Object
      Returns:
      原始事件内容
    • cause

      @NotNull public @NotNull org.spongepowered.api.event.Cause cause()
      Specified by:
      cause in interface org.spongepowered.api.event.Event