Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Apr 14, 2024
1 parent 5850cf9 commit f7276b0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public List<Role> getRoleList() {
Result result = bot.getApi().V2.getRoleApi().getRoleList(getIslandSourceId());
if (result.isFailure()) {
log.error("获取身份组信息失败, 错误消息:{};状态code:{};错误数据:{}", result.getMessage(), result.getStatusCode(), result.getJSONObjectData());
return new ArrayList<>();
return null;
}
List<JSONObject> list = result.getJSONObjectData().getJSONArray("data").toList().stream().map((o) -> {
if (o instanceof Map<?, ?> map) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package io.github.minecraftchampions.dodoopenjava.impl;

import io.github.minecraftchampions.dodoopenjava.Result;
import io.github.minecraftchampions.dodoopenjava.api.*;
import io.github.minecraftchampions.dodoopenjava.api.Bot;
import io.github.minecraftchampions.dodoopenjava.api.Channel;
import io.github.minecraftchampions.dodoopenjava.api.ChannelType;
import io.github.minecraftchampions.dodoopenjava.api.User;
import io.github.minecraftchampions.dodoopenjava.message.Emoji;
import io.github.minecraftchampions.dodoopenjava.message.Message;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* 消息频道实现
*/
@Slf4j
public class MessageChannel extends ChannelImpl {

private MessageChannel(@NonNull String channelId, @NonNull String islandSourceId, @NonNull Bot bot) {
Expand Down Expand Up @@ -89,7 +96,7 @@ public Result withdrawMessage(@NonNull String messageId, String reason) {
* @return result
*/
public Result pinMessage(@NonNull String messageId) {
return null;
return getBot().getApi().V2.getChannelMessageApi().setChannelMessageTop(messageId,1);
}

/**
Expand All @@ -99,7 +106,7 @@ public Result pinMessage(@NonNull String messageId) {
* @return result
*/
public Result unpinMessage(@NonNull String messageId) {
return null;
return getBot().getApi().V2.getChannelMessageApi().setChannelMessageTop(messageId,0);
}

/**
Expand All @@ -109,7 +116,23 @@ public Result unpinMessage(@NonNull String messageId) {
* @return 反应列表(前为反应表情,后为数量)
*/
public Map<Emoji, Integer> getMessageReactionList(@NonNull String messageId) {
return null;
Result result = getBot().getApi().V2.getChannelMessageApi().getChannelMessageReactionList(messageId);
if (result.isFailure()) {
log.error("获取消息信息失败, 错误消息:{};状态code:{};错误数据:{}", result.getMessage(), result.getStatusCode(), result.getJSONObjectData());
return null;
}
List<JSONObject> list = result.getJSONObjectData().getJSONArray("data").toList().stream().map((o) -> {
if (o instanceof Map<?, ?> map) {
return new JSONObject(map);
}
return new JSONObject();
}).toList();
Map<Emoji, Integer> map = new HashMap<>();
list.forEach((jsonObject) -> {
Emoji emoji = Emoji.of(jsonObject.getJSONObject("emoji").getString("id"));
map.put(emoji, jsonObject.getInt("count"));
});
return map;
}

/**
Expand All @@ -130,7 +153,7 @@ public List<User> getMessageReactionMemberList(@NonNull String messageId, @NonNu
* @param emoji 消息反应
* @return result
*/
public Result addMessageReactionList(@NonNull String messageId, @NonNull Emoji emoji) {
public Result addMessageReaction(@NonNull String messageId, @NonNull Emoji emoji) {
return null;
}

Expand All @@ -141,7 +164,7 @@ public Result addMessageReactionList(@NonNull String messageId, @NonNull Emoji e
* @param emoji 消息反应
* @return result
*/
public Result removeMessageReactionMemberList(@NonNull String messageId, @NonNull Emoji emoji) {
public Result removeMessageReaction(@NonNull String messageId, @NonNull Emoji emoji) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.json.JSONObject;

/**
* 消息反应
*/
@Data
@RequiredArgsConstructor
@AllArgsConstructor(staticName = "of")
public class Emoji {
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
public class Permission {
@NonNull
private int value;

/**
Expand Down

0 comments on commit f7276b0

Please sign in to comment.