update
This commit is contained in:
parent
be3e3bbf9d
commit
57ec517608
@ -152,6 +152,10 @@ public class Live implements ApplicationContextAware {
|
||||
header.put("Pragma", "no-cache");
|
||||
header.put("Upgrade", "websocket");
|
||||
header.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36");
|
||||
if (client != null && !client.isClosed()) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
client = new WebSocketClient(new URI(url), header) {
|
||||
private long time = 0;
|
||||
private boolean init = true;
|
||||
@ -223,6 +227,14 @@ public class Live implements ApplicationContextAware {
|
||||
}
|
||||
};
|
||||
client.connect();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (client == null || client.isClosed()) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}, 0, 60 * 1000);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@ -351,17 +363,7 @@ public class Live implements ApplicationContextAware {
|
||||
String danmu;
|
||||
GiftData giftData;
|
||||
Log.i(AppTools.getToDayTime(), roomId, json.toJSONString());
|
||||
switch (json.getString("cmd")) {
|
||||
case "INTERACT_WORD"://普通用户进直播间
|
||||
danmu = json.getJSONObject("data").getString("uname") + " 进入到直播间";
|
||||
liveData.setUid(json.getJSONObject("data").getInteger("uid"));
|
||||
liveData.setType(LiveData.INTERACT_WORD);
|
||||
liveData.setMsg(danmu);
|
||||
liveData.setRoomid(roomId);
|
||||
liveData.setSubtime(new Date());
|
||||
service.addLiveData(liveData);
|
||||
break;
|
||||
case "DANMU_MSG"://普通弹幕
|
||||
if (json.getString("cmd").startsWith("DANMU_MSG")) {//普通弹幕
|
||||
JSONArray infoData = json.getJSONArray("info");
|
||||
danmu = json.getJSONArray("info").getString(1);
|
||||
DanmuData danmuData = new DanmuData();
|
||||
@ -379,6 +381,19 @@ public class Live implements ApplicationContextAware {
|
||||
danmuManager.addDanmu(danmuData);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (json.getString("cmd")) {
|
||||
case "INTERACT_WORD"://普通用户进直播间
|
||||
danmu = json.getJSONObject("data").getString("uname") + " 进入到直播间";
|
||||
liveData.setUid(json.getJSONObject("data").getInteger("uid"));
|
||||
liveData.setType(LiveData.INTERACT_WORD);
|
||||
liveData.setMsg(danmu);
|
||||
liveData.setRoomid(roomId);
|
||||
liveData.setSubtime(new Date());
|
||||
service.addLiveData(liveData);
|
||||
break;
|
||||
case "DANMU_MSG":
|
||||
|
||||
break;
|
||||
case "SEND_GIFT"://送礼
|
||||
data = json.getJSONObject("data");
|
||||
@ -530,7 +545,7 @@ public class Live implements ApplicationContextAware {
|
||||
//com.yutou.bilibili.Tools.Log.i(msg);
|
||||
break;
|
||||
default:
|
||||
com.yutou.bilibili.Tools.Log.i("["+roomId+"]"+msg);
|
||||
Log.i("[" + roomId + "]" + msg);
|
||||
liveData = new BilibiliLiveData();
|
||||
liveData.setType(LiveData.UNKNOWN_MESSAGE);
|
||||
liveData.setUid(-1);
|
||||
@ -539,6 +554,7 @@ public class Live implements ApplicationContextAware {
|
||||
liveData.setSubtime(new Date());
|
||||
service.addLiveData(liveData);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
Log.i(AppTools.getToDayTimeToString(startTime), roomId, e.getLocalizedMessage());
|
||||
|
@ -13,7 +13,7 @@ import org.springframework.context.annotation.Import;
|
||||
@SpringBootApplication
|
||||
public class BilibiliApplication {
|
||||
|
||||
public static String version="0.7.4.5";
|
||||
public static String version="0.7.4.7";
|
||||
|
||||
public static void main(String[] args) {
|
||||
QQBotManager.getInstance().init();
|
||||
|
@ -58,6 +58,7 @@ public class QQBotManager implements ApplicationContextAware {
|
||||
private final static String QQ_LIVE_TO_DAY_DATE = "!今日数据";
|
||||
private final static String QQ_LIVE_DATE = "!数据";
|
||||
private final static String QQ_LIVE_USE_SAVE = "!启动录播";
|
||||
private final static String QQ_LIVE_RELINK="!relink";
|
||||
}
|
||||
|
||||
private static QQBotManager botManager = null;
|
||||
@ -308,6 +309,11 @@ public class QQBotManager implements ApplicationContextAware {
|
||||
}
|
||||
getInstance().sendMessage(builder.toString());
|
||||
break;
|
||||
case QQCommands.QQ_LIVE_RELINK:
|
||||
for (Live live : Live.lives.values()) {
|
||||
live.stop();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (msg.startsWith(QQCommands.QQ_LIVE_TO_DAY_DATE)) {
|
||||
try {
|
||||
|
@ -33,26 +33,30 @@ public class BilibiliLiveInfo implements Serializable {
|
||||
}
|
||||
|
||||
public Integer getPopular() {
|
||||
if(popular==null)
|
||||
if(popular==null) {
|
||||
popular=0;
|
||||
}
|
||||
return popular;
|
||||
}
|
||||
|
||||
public Integer getUserindex() {
|
||||
if(userindex==null)
|
||||
if(userindex==null) {
|
||||
userindex=0;
|
||||
}
|
||||
return userindex;
|
||||
}
|
||||
|
||||
public Integer getVipuserindex() {
|
||||
if(vipuserindex==null)
|
||||
if(vipuserindex==null) {
|
||||
vipuserindex=0;
|
||||
}
|
||||
return vipuserindex;
|
||||
}
|
||||
|
||||
public Integer getGiftuser() {
|
||||
if(giftuser==null)
|
||||
if(giftuser==null) {
|
||||
giftuser=0;
|
||||
}
|
||||
return giftuser;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user