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>
<groupId>org.springframework.boot</groupId>
<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>
</plugins>
<resources>

View File

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

View File

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