Compare commits

..

No commits in common. "main" and "drink-water" have entirely different histories.

14 changed files with 79 additions and 104 deletions

View File

@ -1,18 +1,19 @@
name: Mirai-build name: Gitea Actions Demo
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: | - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
rm -rf ./* - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
git clone $BARE_REPO_DIR $CLONED_REPO_DIR - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- run: pwd - name: Check out repository code
# - run: ls -sl uses: actions/checkout@v4
# - run: chmod +x ./mvnw - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to 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 - run: echo "🖥️ The workflow is now ready to test your code on the runner."
- run: docker build -t mirai-bot:latest - name: List files in the repository
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
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://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://mirrors.huaweicloud.com/repository/maven//org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip

View File

@ -1,13 +0,0 @@
#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

12
KFCFactory.json Normal file
View File

@ -0,0 +1,12 @@
{
"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"
}
}

17
android_pad.json Normal file
View File

@ -0,0 +1,17 @@
{
"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
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://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 http://www.apache.org/licenses/LICENSE-2.0 @REM https://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,37 +42,11 @@
<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>
@ -121,16 +95,9 @@
</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-api-jvm</artifactId> <artifactId>mirai-core-jvm</artifactId>
<version>2.16.0</version> <version>2.16.0</version>
</dependency> </dependency>
@ -155,6 +122,13 @@
<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,9 +1,11 @@
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
@ -11,5 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling
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,14 +2,15 @@ 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
/** /**
@ -22,13 +23,15 @@ class BotConfiguration {
@Bean @Bean
fun bot(config: BotConfig): Bot { fun bot(config: BotConfig): Bot {
val connect = runBlocking { return when (config.type) {
val bot = async { LoginType.PASSWORD -> BotFactory.newBot(config.id, config.password) {
BotBuilder.positive(config.ws).token(config.token).connect() ?: throw Exception("Bot connect failed") extracted()
}
LoginType.QRCODE -> BotFactory.newBot(config.id, BotAuthorization.byQRCode()) {
extracted()
} }
bot.await()
} }
return connect
} }
@Bean("functionMap") @Bean("functionMap")
@ -54,4 +57,10 @@ class BotConfiguration {
} }
return eventMap return eventMap
} }
private fun BotConfiguration.extracted() {
fileBasedDeviceInfo()
protocol = BotConfiguration.MiraiProtocol.ANDROID_PAD
enableContactCache()
}
} }

View File

@ -15,31 +15,18 @@ 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
*/ */
@ -47,13 +34,10 @@ class BotConfig {
constructor() constructor()
constructor(id: Long, password: String, type: LoginType, ws: String, token: String, admin: Long) { constructor(id: Long, password: String, type: LoginType, 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,4 +8,5 @@ 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

@ -1,14 +0,0 @@
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: mirai username: root
password: FydsaZsFm5w26We6 password: FydsaZsFm5w26We6