fix B站添加直播间失败

This commit is contained in:
Yutousama 2022-10-14 21:11:31 +08:00
parent 00985e7fb8
commit 07361fb616
2 changed files with 25 additions and 10 deletions

View File

@ -20,7 +20,8 @@ public class BiliBiliLive extends Model {
@Override
public String[] getUsePowers() {
return new String[]{
Model.QQGroupCommands.BILI_LIVE_DANMU_SEND
Model.QQGroupCommands.BILI_LIVE_DANMU_SEND,
QQGroupCommands.BILI_LIVE_DANMU_DEL
};
}
@ -47,26 +48,39 @@ public class BiliBiliLive extends Model {
@Override
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
super.onMessage(qq, event, isGroup);
if (!msg.startsWith(QQGroupCommands.BILI_LIVE_DANMU_SEND)) {
if (!msg.startsWith(QQGroupCommands.BILI_LIVE_DANMU_SEND) && !msg.startsWith(QQGroupCommands.BILI_LIVE_DANMU_DEL)) {
return;
}
StringBuilder message;
message = new StringBuilder();
try {
Integer roomId = Integer.getInteger(msg);
if (BiliBiliUtils.checkLiveRoom(roomId) && !RedisTools.list_isExist("bili_live", roomId + "")) {
RedisTools.list_add("bili_live", roomId + "");
message = new StringBuilder("live sign Add Success");
boolean isDel = false;
if (msg.startsWith(QQGroupCommands.BILI_LIVE_DANMU_DEL)) {
isDel = true;
msg = msg.replace(QQGroupCommands.BILI_LIVE_DANMU_DEL, "").trim();
} else {
message = new StringBuilder("live sign Add Error\n");
message.append("-----live sign roomId-----\n");
msg = msg.replace(QQGroupCommands.BILI_LIVE_DANMU_SEND, "").trim();
}
Integer roomId = Integer.getInteger(msg);
if (BiliBiliUtils.checkLiveRoom(roomId)) {
if (isDel && RedisTools.list_isExist("bili_live", roomId + "")) {
RedisTools.list_remove("bili_live", roomId + "");
message.append("直播签到删除成功").append("\n");
} else if (!RedisTools.list_isExist("bili_live", roomId + "")) {
RedisTools.list_add("bili_live", roomId + "");
message.append("直播签到添加成功").append("\n");
}
} else {
message.append("直播签到操作失败\n");
message.append("-----直播签到房间号----\n");
Set<String> biliLive = RedisTools.list_get("bili_live");
for (String id : biliLive) {
message.append(id).append("\n");
}
}
} catch (Exception e) {
message = new StringBuilder("live sign Add Error\n");
message.append("-----live sign roomId-----\n");
message = new StringBuilder("直播签到添加失败\n");
message.append("-----直播签到房间号-----\n");
Set<String> biliLive = RedisTools.list_get("bili_live");
for (String id : biliLive) {
message.append(id).append("\n");

View File

@ -36,6 +36,7 @@ public abstract class Model implements ModelInterface {
public final static String QQ_MOYU = "!摸鱼";
public final static String BILI_LIVE_DANMU_SEND="!b站签到";
public final static String BILI_LIVE_DANMU_DEL="!b站签到删除";
}