[Add][Change] Framework-API 将 Message 正式代替 String 作为消息内容对象, 为 Framework 添加方便获取 Platform 对象的方法;

[Add] Framework 添加 `getPlatform` 方法以便捷得获取 Platform 对象;
[Change] MessageSender 使用 Message 代替 String 作为消息内容对象;
This commit is contained in:
LamGC 2020-11-21 22:01:57 +08:00
parent 561dd58611
commit ba2ced9a1e
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
2 changed files with 12 additions and 2 deletions

View File

@ -88,6 +88,16 @@ public abstract class Framework extends Plugin {
throw new IllegalStateException("无法转换 Descriptor 的类型, 框架管理器可能遭到修改!"); throw new IllegalStateException("无法转换 Descriptor 的类型, 框架管理器可能遭到修改!");
} }
/**
* 获取框架所属平台.
* <p> 等效于
* <pre> {@link #getDescriptor()}.{@link FrameworkDescriptor#getPlatform() getPlatform()}
* @return 返回平台对象.
*/
public Platform getPlatform() {
return getDescriptor().getPlatform();
}
/** /**
* 获取当前框架对象与所属 ContentGrabbingJiBot 的上下文. * 获取当前框架对象与所属 ContentGrabbingJiBot 的上下文.
* @return 返回上下文对象. * @return 返回上下文对象.

View File

@ -68,11 +68,11 @@ public interface MessageSender {
* @param message 消息内容, 特殊内容将以功能码形式插入内容中. * @param message 消息内容, 特殊内容将以功能码形式插入内容中.
* @return 如果成功返回 0 或消息 Id, 发送失败返回负数代表错误码. * @return 如果成功返回 0 或消息 Id, 发送失败返回负数代表错误码.
*/ */
int sendMessage(String message); int sendMessage(Message message);
/** /**
* 获取消息标识, 用于回复/撤回功能 * 获取消息标识, 用于回复/撤回功能
* @param msgId 消息Id, 通过 {@link #sendMessage(String)} 发送消息获得, 或从 MessageEvent 中获得. * @param msgId 消息Id, 通过 {@link #sendMessage(Message)} 发送消息获得, 或从 MessageEvent 中获得.
* @return 如果成功获取, 返回非null值, 如果不存在或无法获取, 返回 null. * @return 如果成功获取, 返回非null值, 如果不存在或无法获取, 返回 null.
*/ */
String getMessageIdentify(int msgId); String getMessageIdentify(int msgId);