Compare commits

...

24 Commits

Author SHA1 Message Date
Grand-cocoa
e7ad348544 修改打包方式Action
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 9s
2024-12-26 14:37:13 +08:00
Grand-cocoa
7cedd4e152 修改依赖库
All checks were successful
Mirai-build / Explore-Gitea-Actions (push) Successful in 2s
2024-12-26 14:33:54 +08:00
Grand-cocoa
7d36b6d9dc 修改依赖库
All checks were successful
Mirai-build / Explore-Gitea-Actions (push) Successful in 2s
2024-12-26 14:30:47 +08:00
Grand-cocoa
84c2a7d82d 修改依赖库
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 11s
2024-12-26 14:20:25 +08:00
Grand-cocoa
787520c98b 修改 打包方式
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 12s
2024-12-26 14:16:22 +08:00
Grand-cocoa
f818241731 修改 实现改为workflow
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 26s
2024-12-25 19:08:33 +08:00
Grand-cocoa
10ed0dc703 ```更改数据库用户名以符合专用配置
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
将应用的数据库用户名从root更改为mirai,以符合专用的数据库配置设置。此次更改对于与特定环境要求保持一致是必要的。
```
2024-09-18 19:04:27 +08:00
Grand-cocoa
f4475cd09d ```在Dockerfile中添加WORKDIR指令
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
在Dockerfile中包含WORKDIR指令,确保容器内的默认工作目录设置为/opt。此更改对于在容器启动时正确执行后续命令至关重要。
```
2024-09-18 18:56:15 +08:00
Grand-cocoa
3aadf53e0e 明确指定配置文件添加路径
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
更新了Dockerfile以指定配置文件的确切路径。这确保了`android_pad.json`、`device.json`和`KFCFactory.json`文件将被正确地添加到容器的`/opt`目录下,而不是基于当前工作目录的相对路径。此更改对于避免在构建Docker镜像期间的路径解析问题至关重要。
2024-09-18 18:52:25 +08:00
Grand-cocoa
a7fcb58f98 ```更新Docker镜像中的启动配置和文件
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
将Dockerfile中的主要启动文件从'spring-boot-docker.jar'更新为'Mirai-bot.jar',并相应地调整了ENTRYPOINT命令。不再使用的旧文件已从镜像构建脚本中移除,确保Docker镜像配置与新的项目文件对齐。
```
2024-09-18 18:51:04 +08:00
Grand-cocoa
80a782f41d ```优化Dockerfile中的命令执行
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 11s
将'CMD'指令更改为'ENTRYPOINT',以允许更好地控制Spring Boot应用程序的启动方式。此更改使得在容器启动时能够更灵活地传递参数给Java命令。
```
2024-09-18 18:48:36 +08:00
Grand-cocoa
2fed165aba 添加华为云插件仓库以支持maven构建
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 13s
2024-09-18 18:44:48 +08:00
Grand-cocoa
67ac79e17f 添加华为云仓库以支持新插件的集成
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
2024-09-18 18:20:23 +08:00
Grand-cocoa
791fee74d4 工作流优化:简化仓库克隆路径配置
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
在Gitea Actions工作流中,已更新仓库克隆目录的路径设置,以简化为当前目录下的相对路径。这样做旨在避免潜在的权限问题,并使工作流的配置更加清晰。
2024-09-18 17:57:25 +08:00
Grand-cocoa
3b3d5b6fa6 工作流优化:简化仓库克隆路径配置
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 2s
在Gitea Actions工作流中,已更新仓库克隆目录的路径设置,以简化为当前目录下的相对路径。这样做旨在避免潜在的权限问题,并使工作流的配置更加清晰。
2024-09-18 17:56:47 +08:00
Grand-cocoa
4b3deaa520 修正构建和测试工作流中的目录变更错误
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
之前的工作流配置错误地从根目录运行命令,而不是从预期的子目录运行。此更改确保命令在正确的项目目录中执行,以避免任何构建或测试过程中的潜在错误。
2024-09-18 17:54:06 +08:00
Grand-cocoa
45f79398fd ```在构建测试工作流中添加初始化步骤
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
添加了两个新步骤来打印当前工作目录和列出克隆存储库目录的内容。这将帮助诊断克隆和构建过程中遇到的任何问题。

更改前:```
rm -rf $CLONED_REPO_DIR
git clone $BARE_REPO_DIR $CLONED_REPO_DIR
run: cd $CLONED_REPO_DIR
run: chmod +x ./mvnw
run: sh ./mvnw -DskipTests=true clean package -P prod
run: docker build -t mirai-bot:latest
```

更改后:
```
rm -rf $CLONED_REPO_DIR
git clone $BARE
2024-09-18 17:52:51 +08:00
Grand-cocoa
24179727ed ```将BARE_REPO_DIR更新为远程URL
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 10s
将BARE_REPO_DIR环境变量的值从本地路径更改为完整的远程Git仓库URL,以便正确配置仓库位置。
```
2024-09-18 17:51:50 +08:00
Grand-cocoa
27755a6d7b ```设置Mirai-bot项目构建测试工作流
Some checks failed
Mirai-build / Explore-Gitea-Actions (push) Failing after 2s
更新了Gitea Actions的配置,使其能够适配Mirai-bot项目的构建和测试。工作流被重命名为“Mirai-build”,并且新的环境变量指定了裸仓库和克隆仓库的目录。此外,流程中包含了一个新的步骤,用于克隆仓库,并且运行的命令现在会导航到克隆的目录并使`mvnw`可执行。
```
2024-09-18 17:49:53 +08:00
Grand-cocoa
47fbae8703 修正构建流程中的工作目录错误在Gitea的CI/CD流程中,更新了build-test.yaml文件,以明确构建脚本的执行路径。此更改确保构建脚本在正确的目录下执行,避免因路径问题导致的构建错误。
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2s
2024-09-18 17:42:16 +08:00
Grand-cocoa
a941c05a75 修正构建流程中的工作目录错误在Gitea的CI/CD流程中,更新了build-test.yaml文件,以明确构建脚本的执行路径。此更改确保构建脚本在正确的目录下执行,避免因路径问题导致的构建错误。
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 3s
2024-09-18 17:41:30 +08:00
Grand-cocoa
8f532c5686 修正构建流程中的工作目录错误在Gitea的CI/CD流程中,更新了build-test.yaml文件,以明确构建脚本的执行路径。此更改确保构建脚本在正确的目录下执行,避免因路径问题导致的构建错误。
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2s
2024-09-18 17:40:39 +08:00
Grand-cocoa
f81ddde881 ```使用华为云Maven镜像更新Maven依赖项
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2s
此提交通过修改Maven配置文件和包装脚本,将Maven依赖项来源更新为华为云镜像。此更改旨在优化Maven包的下载速度和稳定性。
```
2024-09-18 17:36:11 +08:00
Grand-cocoa
ee6403eb7d ```工作流更新与设备信息添加
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 2s
- 重构`.gitea/workflows/build-test.yaml`,优化Maven构建流程,省略非必要步骤。
- 实现`device.json`文件,模拟设备信息,适用于mirai设备。
- 更新`Dockerfile`,自动化构建流程,包括必要的配置文件。
```
2024-09-18 17:25:48 +08:00
14 changed files with 104 additions and 79 deletions

View File

@ -1,19 +1,18 @@
name: Gitea Actions Demo name: Mirai-build
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [ push ] on: [ push ]
env:
BARE_REPO_DIR: https://git.alina-dace.info/Dace/Mirai-bot.git
CLONED_REPO_DIR: ./
jobs: jobs:
Explore-Gitea-Actions: Explore-Gitea-Actions:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - run: |
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" rm -rf ./*
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." git clone $BARE_REPO_DIR $CLONED_REPO_DIR
- name: Check out repository code - run: pwd
uses: actions/checkout@v4 # - run: ls -sl
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." # - run: chmod +x ./mvnw
- run: echo "🖥️ The workflow is now ready to test your code on the runner." - run: docker run -it --rm --name my-maven-project -v "$(pwd)":/usr/src/mymaven -v maven-repo:/root/.m2 -w /usr/src/mymaven maven mvn -DskipTests=true clean package -P prod-remote
- name: List files in the repository - run: docker build -t mirai-bot:latest
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."

View File

@ -6,7 +6,7 @@
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# https://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an
@ -16,4 +16,4 @@
# under the License. # under the License.
wrapperVersion=3.3.2 wrapperVersion=3.3.2
distributionType=only-script distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip distributionUrl=https://mirrors.huaweicloud.com/repository/maven//org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
#FROM maven as builder
#WORKDIR /app
#COPY . .
#RUN mvn clean package
FROM bellsoft/liberica-openjdk-debian:17.0.11-cds
LABEL authors="Kane"
WORKDIR /opt
#COPY --from=builder /app/target/Mirai-bot-0.0.1-SNAPSHOT.jar /opt/Mirai-bot.jar
COPY target/Mirai-bot-0.0.1-SNAPSHOT.jar /opt/Mirai-bot.jar
ENTRYPOINT java -jar /opt/Mirai-bot.jar

View File

@ -1,12 +0,0 @@
{
"9.0.56": {
"base_url": "https://qsign.trpgbot.com",
"type": "fuqiuluo/unidbg-fetch-qsign",
"key": "114514"
},
"9.0.95": {
"base_url": "https://qsign.trpgbot.com",
"type": "fuqiuluo/unidbg-fetch-qsign",
"key": "114514"
}
}

View File

@ -1,17 +0,0 @@
{
"apk_id": "com.tencent.mobileqq",
"app_id": 537220362,
"sub_app_id": 537220362,
"app_key": "0S200MNJT807V3GE",
"sort_version_name": "9.0.56.16830",
"build_time": 1713424357,
"apk_sign": "a6b745bf24a2c277527716f6f36eb68d",
"sdk_version": "6.0.0.2560",
"sso_version": 21,
"misc_bitmap": 150470524,
"main_sig_map": 34869472,
"sub_sig_map": 66560,
"dump_time": 1713424357,
"qua": "V1_AND_SQ_9.0.56_6372_YYB_D",
"protocol_type": 6
}

2
mvnw vendored
View File

@ -8,7 +8,7 @@
# "License"); you may not use this file except in compliance # "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at # with the License. You may obtain a copy of the License at
# #
# https://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, # Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an # software distributed under the License is distributed on an

2
mvnw.cmd vendored
View File

@ -8,7 +8,7 @@
@REM "License"); you may not use this file except in compliance @REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at @REM with the License. You may obtain a copy of the License at
@REM @REM
@REM https://www.apache.org/licenses/LICENSE-2.0 @REM http://www.apache.org/licenses/LICENSE-2.0
@REM @REM
@REM Unless required by applicable law or agreed to in writing, @REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an @REM software distributed under the License is distributed on an

42
pom.xml
View File

@ -42,11 +42,37 @@
<profiles.active>prod</profiles.active> <profiles.active>prod</profiles.active>
</properties> </properties>
</profile> </profile>
<profile>
<id>prod-remote</id>
<properties>
<profiles.active>prod-remote</profiles.active>
</properties>
</profile>
</profiles> </profiles>
<properties> <properties>
<java.version>17</java.version> <java.version>17</java.version>
<kotlin.version>1.9.25</kotlin.version> <kotlin.version>1.9.25</kotlin.version>
</properties> </properties>
<repositories>
<repository>
<id>HuaweiCloud</id>
<name>HuaweiCloud</name>
<url>https://mirrors.huaweicloud.com/repository/maven</url>
</repository>
<!-- Maven 官方仓库 -->
<repository>
<id>MavenOfficial</id>
<name>MavenOfficial</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>HuaweiCloud</id>
<name>HuaweiCloud</name>
<url>https://mirrors.huaweicloud.com/repository/maven</url>
</pluginRepository>
</pluginRepositories>
<dependencies> <dependencies>
<!-- 运行依赖 --> <!-- 运行依赖 -->
<dependency> <dependency>
@ -95,9 +121,16 @@
</dependency> </dependency>
<!-- 核心 机器人 --> <!-- 核心 机器人 -->
<!-- https://mvnrepository.com/artifact/top.mrxiaom.mirai/overflow-core -->
<dependency>
<groupId>top.mrxiaom.mirai</groupId>
<artifactId>overflow-core</artifactId>
<version>1.0.1</version>
</dependency>
<dependency> <dependency>
<groupId>net.mamoe</groupId> <groupId>net.mamoe</groupId>
<artifactId>mirai-core-jvm</artifactId> <artifactId>mirai-core-api-jvm</artifactId>
<version>2.16.0</version> <version>2.16.0</version>
</dependency> </dependency>
@ -122,13 +155,6 @@
<artifactId>async-http-client</artifactId> <artifactId>async-http-client</artifactId>
<version>3.0.0</version> <version>3.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>xyz.cssxsh.mirai</groupId>
<artifactId>fix-protocol</artifactId>
<version>3.3.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/fix-protocol-version-1.13.0.mirai2.jar</systemPath>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,11 +1,9 @@
package info.alinadace.miraibot package info.alinadace.miraibot
import net.mamoe.mirai.utils.BotConfiguration
import org.mybatis.spring.annotation.MapperScan import org.mybatis.spring.annotation.MapperScan
import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication import org.springframework.boot.runApplication
import org.springframework.scheduling.annotation.EnableScheduling import org.springframework.scheduling.annotation.EnableScheduling
import xyz.cssxsh.mirai.tool.FixProtocolVersion
@SpringBootApplication @SpringBootApplication
@EnableScheduling @EnableScheduling
@ -13,7 +11,5 @@ import xyz.cssxsh.mirai.tool.FixProtocolVersion
class MiraiBotApplication class MiraiBotApplication
fun main(args: Array<String>) { fun main(args: Array<String>) {
// FixProtocolVersion.fetch(BotConfiguration.MiraiProtocol.ANDROID_PHONE, "8.9.96")
FixProtocolVersion.load(BotConfiguration.MiraiProtocol.ANDROID_PAD)
runApplication<MiraiBotApplication>(*args) runApplication<MiraiBotApplication>(*args)
} }

View File

@ -2,15 +2,14 @@ package info.alinadace.miraibot.bean
import info.alinadace.miraibot.annotation.BotFunction import info.alinadace.miraibot.annotation.BotFunction
import info.alinadace.miraibot.configuration.BotConfig import info.alinadace.miraibot.configuration.BotConfig
import info.alinadace.miraibot.enums.LoginType
import info.alinadace.miraibot.service.Service import info.alinadace.miraibot.service.Service
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import net.mamoe.mirai.Bot import net.mamoe.mirai.Bot
import net.mamoe.mirai.BotFactory
import net.mamoe.mirai.auth.BotAuthorization
import net.mamoe.mirai.event.Event import net.mamoe.mirai.event.Event
import net.mamoe.mirai.utils.BotConfiguration
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
import top.mrxiaom.overflow.BotBuilder
import kotlin.reflect.KClass import kotlin.reflect.KClass
/** /**
@ -23,15 +22,13 @@ class BotConfiguration {
@Bean @Bean
fun bot(config: BotConfig): Bot { fun bot(config: BotConfig): Bot {
return when (config.type) { val connect = runBlocking {
LoginType.PASSWORD -> BotFactory.newBot(config.id, config.password) { val bot = async {
extracted() BotBuilder.positive(config.ws).token(config.token).connect() ?: throw Exception("Bot connect failed")
}
LoginType.QRCODE -> BotFactory.newBot(config.id, BotAuthorization.byQRCode()) {
extracted()
} }
bot.await()
} }
return connect
} }
@Bean("functionMap") @Bean("functionMap")
@ -57,10 +54,4 @@ class BotConfiguration {
} }
return eventMap return eventMap
} }
private fun BotConfiguration.extracted() {
fileBasedDeviceInfo()
protocol = BotConfiguration.MiraiProtocol.ANDROID_PAD
enableContactCache()
}
} }

View File

@ -15,18 +15,31 @@ class BotConfig {
/** /**
* 机器人QQ号 * 机器人QQ号
*/ */
@Deprecated(message = "内部认证已失效")
final var id: Long = 0L final var id: Long = 0L
/** /**
* 机器人密码 * 机器人密码
*/ */
@Deprecated(message = "内部认证已失效")
final var password: String = "" final var password: String = ""
/** /**
* 机器人登录方式 * 机器人登录方式
*/ */
@Deprecated(message = "内部认证已失效")
final var type: LoginType = LoginType.PASSWORD final var type: LoginType = LoginType.PASSWORD
/**
* 机器人ws地址
*/
final var ws: String = ""
/**
* 机器人token
*/
final var token: String = ""
/** /**
* 管理员QQ * 管理员QQ
*/ */
@ -34,10 +47,13 @@ class BotConfig {
constructor() constructor()
constructor(id: Long, password: String, type: LoginType, admin: Long) { constructor(id: Long, password: String, type: LoginType, ws: String, token: String, admin: Long) {
this.id = id this.id = id
this.password = password this.password = password
this.type = type this.type = type
this.ws = ws
this.token = token
this.admin = admin this.admin = admin
} }
} }

View File

@ -8,5 +8,4 @@ import info.alinadace.miraibot.service.drink_water.domain.DrinkWaterUser
* @author Kane * @author Kane
* @since 2024/9/18 13:39 * @since 2024/9/18 13:39
*/ */
interface DrinkWaterMapper : BaseMapper<DrinkWaterUser> { interface DrinkWaterMapper : BaseMapper<DrinkWaterUser>
}

View File

@ -0,0 +1,14 @@
bot:
id: 3437522130
type: password
password: nobuts001
spring:
data:
redis:
host: 101.35.164.171
password: wTE32JjsieQ2JTOwsg9X
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://101.35.164.171:3306/mirai?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: mirai
password: FydsaZsFm5w26We6

View File

@ -10,5 +10,5 @@ spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.0.4.16:3306/mirai?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true url: jdbc:mysql://10.0.4.16:3306/mirai?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root username: mirai
password: FydsaZsFm5w26We6 password: FydsaZsFm5w26We6