升级QQ机器人

调整直播状态代码
调整录像路径
This commit is contained in:
Yutousama 2022-04-10 21:43:19 +08:00
parent 251ebe1a0c
commit d2f0be5adb
5 changed files with 64 additions and 63 deletions

38
pom.xml
View File

@ -15,7 +15,7 @@
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<kotlin.version>1.4.10</kotlin.version>
<kotlin.version>1.6.10</kotlin.version>
</properties>
<dependencies>
<dependency>
@ -54,23 +54,23 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.73</version>
<version>1.2.80</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.28.0</version>
<version>3.36.0.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
@ -80,45 +80,50 @@
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>3.17</version>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>net.mamoe</groupId>
<artifactId>mirai-core-jvm</artifactId>
<version>2.5.0</version> <!-- 替换版本为你需要的版本 -->
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-jdk8</artifactId>
<version>1.6.0-native-mt</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core-jvm</artifactId>
<version>1.6.0-native-mt</version>
</dependency>
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.6.0-RC1</version>
<version>4.2.0</version>
</dependency>
</dependencies>
@ -181,9 +186,6 @@
</goals>
<configuration>
<outputDirectory>
Z:\servier\biliob\
</outputDirectory>
</configuration>
</execution>

View File

@ -108,7 +108,7 @@ public class Live implements ApplicationContextAware {
private void updateUpInfo() {
try {
upData = service.queryUp(upData);
upData.setLive(1);
//upData.setLive(1);
if (upData.getSavedanmu() == 1) {
danmuManager = new BiliBiliLiveDatabasesManager();
danmuManager.init("[" + AppTools.getToDayTime() + "]" + upData.getRoomid());
@ -329,7 +329,6 @@ public class Live implements ApplicationContextAware {
}
public void checkLive() {
boolean isLive = LiveUtils.isLivePlayer(roomId);
upData.setLive(isLive ? 1 : 0);
System.out.println(roomId+"直播状态="+isLive);
@ -354,6 +353,9 @@ public class Live implements ApplicationContextAware {
* @param bytes 原始hex数据
*/
public void processData(String msg, byte[] bytes) {
if(msg.contains("[object Object]")){
return;
}
try {
JSONObject json = JSONObject.parseObject(msg);
JSONObject data;
@ -552,6 +554,7 @@ public class Live implements ApplicationContextAware {
checkLive();
} catch (Exception e) {
Log.e(e);
Log.i("msg = "+msg);
// Log.i(AppTools.getToDayTimeToString(startTime), roomId, e.getLocalizedMessage());
/*try {
JSONObject.parseObject(new String(bytes, StandardCharsets.UTF_8));

View File

@ -5,10 +5,7 @@ import com.yutou.bilibili.BiliBili.Datas.AppData;
import com.yutou.bilibili.BiliBili.Live;
import com.yutou.bilibili.BiliBili.LiveUtils;
import com.yutou.bilibili.QQBot.QQBotManager;
import com.yutou.bilibili.Tools.AppTools;
import com.yutou.bilibili.Tools.FFmpegUtils;
import com.yutou.bilibili.Tools.HttpTools;
import com.yutou.bilibili.Tools.Log;
import com.yutou.bilibili.Tools.*;
import java.io.*;
import java.net.HttpURLConnection;
@ -140,7 +137,8 @@ public class SaveLive {
}
private void ffmpegDownload(String url) throws Exception {
liveFile = new File(String.format("live%s%s%s[%s]%d.mp4",
liveFile = new File(String.format("%slive%s%s%s[%s]%d.mp4",
ConfigTools.load(ConfigTools.CONFIG,"liveSavePath"),
File.separator,
AppTools.getToDayTime(),
File.separator,
@ -189,7 +187,8 @@ public class SaveLive {
heartbeats.put(roomId, heartbeat);
//heartbeats.add(beat);
InputStream inputStream = connection.getInputStream();
liveFile = new File(String.format("live%s%s%s[%s]%d.mp4",
liveFile = new File(String.format("%slive%s%s%s[%s]%d.mp4",
ConfigTools.load(ConfigTools.CONFIG,"liveSavePath"),
File.separator,
AppTools.getToDayTime(),
File.separator,

View File

@ -13,7 +13,7 @@ import org.springframework.context.annotation.Import;
@SpringBootApplication
public class BilibiliApplication {
public static String version="0.8";
public static String version="0.8.3";
public static void main(String[] args) {
QQBotManager.getInstance().init();

View File

@ -84,9 +84,7 @@ public class QQBotManager implements ApplicationContextAware {
if (!((boolean) ConfigTools.load(ConfigTools.CONFIG, "qq_bot"))) {
return;
}
new Thread(new Runnable() {
@Override
public void run() {
new Thread(() -> {
long qq = Long.parseLong((String) ConfigTools.load(ConfigTools.CONFIG, "qq_number"));
String password = (String) ConfigTools.load(ConfigTools.CONFIG, "qq_password");
bot = BotFactory.INSTANCE.newBot(qq, password, new BotConfiguration() {
@ -112,7 +110,7 @@ public class QQBotManager implements ApplicationContextAware {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
com.yutou.bilibili.Tools.Log.e(e);
Log.e(e);
}
String str = sendMessage("姬妻酱上线拉~");
Log.i(str);
@ -121,7 +119,6 @@ public class QQBotManager implements ApplicationContextAware {
}).start();
bot.join();
}
}).start();
}
@ -256,7 +253,7 @@ public class QQBotManager implements ApplicationContextAware {
getInstance().sendMessage("正在重启服务");
System.out.println("结束进程");
try {
AppTools.exec("cd /media/yutou/4t/public/servier/biliob && ./start.sh");
AppTools.exec("cd /home/yutou/public/servier/biliob && ./start.sh");
} catch (Exception e) {
e.printStackTrace();
}