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 @Override
public String[] getUsePowers() { public String[] getUsePowers() {
return new String[]{ 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 @Override
public void onMessage(Long qq, MessageEvent event, boolean isGroup) { public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
super.onMessage(qq, event, 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; return;
} }
StringBuilder message; StringBuilder message;
message = new StringBuilder();
try { try {
Integer roomId = Integer.getInteger(msg); boolean isDel = false;
if (BiliBiliUtils.checkLiveRoom(roomId) && !RedisTools.list_isExist("bili_live", roomId + "")) { if (msg.startsWith(QQGroupCommands.BILI_LIVE_DANMU_DEL)) {
RedisTools.list_add("bili_live", roomId + ""); isDel = true;
message = new StringBuilder("live sign Add Success"); msg = msg.replace(QQGroupCommands.BILI_LIVE_DANMU_DEL, "").trim();
} else { } else {
message = new StringBuilder("live sign Add Error\n"); msg = msg.replace(QQGroupCommands.BILI_LIVE_DANMU_SEND, "").trim();
message.append("-----live sign roomId-----\n"); }
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"); Set<String> biliLive = RedisTools.list_get("bili_live");
for (String id : biliLive) { for (String id : biliLive) {
message.append(id).append("\n"); message.append(id).append("\n");
} }
} }
} catch (Exception e) { } catch (Exception e) {
message = new StringBuilder("live sign Add Error\n"); message = new StringBuilder("直播签到添加失败\n");
message.append("-----live sign roomId-----\n"); message.append("-----直播签到房间号-----\n");
Set<String> biliLive = RedisTools.list_get("bili_live"); Set<String> biliLive = RedisTools.list_get("bili_live");
for (String id : biliLive) { for (String id : biliLive) {
message.append(id).append("\n"); 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 QQ_MOYU = "!摸鱼";
public final static String BILI_LIVE_DANMU_SEND="!b站签到"; public final static String BILI_LIVE_DANMU_SEND="!b站签到";
public final static String BILI_LIVE_DANMU_DEL="!b站签到删除";
} }