This commit is contained in:
yutou 2021-05-12 18:34:09 +08:00
parent 39e9b78581
commit dd1103e870
3 changed files with 43 additions and 8 deletions

21
pom.xml
View File

@ -148,6 +148,27 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--使用-Dloader.path需要在打包的时候增加<layout>ZIP</layout>,不指定的话-Dloader.path不生效-->
<layout>ZIP</layout>
<!-- 指定该jar包启动时的主类[建议] -->
<mainClass>com.yutou.bilibili.BilibiliApplication</mainClass>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<outputDirectory>
Z:\servier\biliob\
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
<resources> <resources>

View File

@ -58,8 +58,9 @@ public class Live implements ApplicationContextAware {
} }
public Live() { public Live() {
if (applicationContext != null) if (applicationContext != null) {
service = getBean(IBiliBiliLiveService.class); service = getBean(IBiliBiliLiveService.class);
}
info = new BilibiliLiveInfo(); info = new BilibiliLiveInfo();
info.setGiftuser(0); info.setGiftuser(0);
info.setPopular(0); info.setPopular(0);
@ -74,6 +75,10 @@ public class Live implements ApplicationContextAware {
* @param isLogin 是否登录用户 * @param isLogin 是否登录用户
*/ */
public void add(int roomId, boolean isLogin) { public void add(int roomId, boolean isLogin) {
if(Live.lives.contains(this)){
Log.i("已经在统计:"+roomId);
return;
}
this.roomId = roomId; this.roomId = roomId;
this.isLogin = isLogin; this.isLogin = isLogin;
upData = new BilibiliUpInfo(); upData = new BilibiliUpInfo();
@ -205,6 +210,7 @@ public class Live implements ApplicationContextAware {
com.yutou.bilibili.Tools.Log.i("code = " + code + ", reason = " + reason + ", remote = " + remote); com.yutou.bilibili.Tools.Log.i("code = " + code + ", reason = " + reason + ", remote = " + remote);
run = false; run = false;
client.close(); client.close();
stop();
} }
@Override @Override
@ -212,6 +218,7 @@ public class Live implements ApplicationContextAware {
Log.e(e); Log.e(e);
run = false; run = false;
client.close(); client.close();
stop();
} }
}; };
client.connect(); client.connect();
@ -227,11 +234,11 @@ public class Live implements ApplicationContextAware {
if (SaveLive.getInstance().checkLive(roomId)) { if (SaveLive.getInstance().checkLive(roomId)) {
SaveLive.getInstance().stop(roomId); SaveLive.getInstance().stop(roomId);
} }
Live.lives.remove(this);
com.yutou.bilibili.Tools.Log.i("退出" + roomId + "直播间");
if (checkLiveTimer != null) { if (checkLiveTimer != null) {
checkLiveTimer.cancel(); checkLiveTimer.cancel();
} }
Live.lives.remove(this);
com.yutou.bilibili.Tools.Log.i("退出" + roomId + "直播间");
} }
/** /**
@ -360,9 +367,10 @@ public class Live implements ApplicationContextAware {
danmuData.setUname(infoData.getJSONArray(2).getString(1)); danmuData.setUname(infoData.getJSONArray(2).getString(1));
if (upData != null && upData.getSavedanmu() == 1) { if (upData != null && upData.getSavedanmu() == 1) {
if (danmuManager != null) if (danmuManager != null) {
danmuManager.addDanmu(danmuData); danmuManager.addDanmu(danmuData);
} }
}
Log.i(AppTools.getToDayTimeToString(startTime),roomId,danmu); Log.i(AppTools.getToDayTimeToString(startTime),roomId,danmu);
break; break;
case "SEND_GIFT"://送礼 case "SEND_GIFT"://送礼
@ -509,6 +517,7 @@ public class Live implements ApplicationContextAware {
case "PK_BATTLE_SETTLE": case "PK_BATTLE_SETTLE":
case "PK_BATTLE_PRE_NEW": case "PK_BATTLE_PRE_NEW":
case "PK_BATTLE_PRE": case "PK_BATTLE_PRE":
case "STOP_LIVE_ROOM_LIST"://不知道是啥停止直播
//com.yutou.bilibili.Tools.Log.i(msg); //com.yutou.bilibili.Tools.Log.i(msg);
@ -579,6 +588,7 @@ public class Live implements ApplicationContextAware {
} }
@Override
public void run() { public void run() {
if (!run) { if (!run) {
cancel(); cancel();

View File

@ -49,7 +49,7 @@ public class QQBotManager implements ApplicationContextAware {
private static class QQCommands { private static class QQCommands {
private final static String QQ_HELP = "!help"; private final static String QQ_HELP = "!help";
private final static String QQ_SYSTEM_LOG = "!log"; private final static String QQ_SYSTEM_LOG = "!log";
private final static String QQ_SYSTEM_STOP = "!stopliveservice"; private final static String QQ_SYSTEM_RESTART = "!restart";
private final static String QQ_GET_IP = "!ip"; private final static String QQ_GET_IP = "!ip";
private final static String QQ_GET_VERSION = "!version"; private final static String QQ_GET_VERSION = "!version";
private final static String QQ_LIVE_LIST = "!列表"; private final static String QQ_LIVE_LIST = "!列表";
@ -250,10 +250,14 @@ public class QQBotManager implements ApplicationContextAware {
case QQCommands.QQ_GET_VERSION: case QQCommands.QQ_GET_VERSION:
sendVersion(); sendVersion();
break; break;
case QQCommands.QQ_SYSTEM_STOP: case QQCommands.QQ_SYSTEM_RESTART:
getInstance().sendMessage("正在停止服务"); getInstance().sendMessage("正在重启服务");
System.out.println("结束进程"); System.out.println("结束进程");
System.exit(0); try {
AppTools.exec("cd /media/yutou/4t/public/servier/biliob && ./start.sh");
} catch (Exception e) {
e.printStackTrace();
}
break; break;
case QQCommands.QQ_LIVE_LIST: case QQCommands.QQ_LIVE_LIST:
builder.append("当前正在记录数据的直播间:"); builder.append("当前正在记录数据的直播间:");