Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Jul 6, 2024
1 parent c51944d commit 65e3196
Show file tree
Hide file tree
Showing 14 changed files with 272 additions and 291 deletions.
58 changes: 20 additions & 38 deletions .github/workflows/Gradle CI.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
name: Gradle CI
name: build

# Controls when the action will run.
on:
# Triggers the workflow on push and pull request events but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master

# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
branches: [ master ]

jobs:

build:

name: Gradle-Build

# The type of runner that the job will run on
runs-on: ubuntu-20.04

# Steps represent a sequence of tasks that will be executed as part of the job
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v3

# Setup JDK
- name: Setup Java JDK
uses: actions/setup-java@v3
- name: Checkout repository
uses: actions/checkout@v2
- name: Java setup
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 11
distribution: 'zulu'
cache: 'gradle'

# Validate Gradle Wrapper
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1.0.5

# Build
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
check-latest: true
- uses: burrunan/gradle-cache-action@v1
name: BuildPluginLegacy
with:
job-id: jdk11
arguments: buildPluginLegacy
gradle-version: wrapper
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: lgz-bot
path: build/mirai/*.jar
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# mirai-console-plugin-template
# mirai-quotly-bot

[Mirai Console](https://github.com/mamoe/mirai-console) 插件模板, 使用 Kotlin + Gradle.

[如何使用](https://github.com/project-mirai/how-to-use-plugin-template)
A qq quotly plugin depend on [quote-api](https://github.com/LyoSU/quote-api)</br>
listenport=3000
20 changes: 18 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
plugins {
val kotlinVersion = "1.6.10"
val kotlinVersion = "1.8.0"
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion

id("net.mamoe.mirai-console") version "2.13.2"
}

group = "org.example"
dependencies {
val overflow_version = "2.16.0-db61867-SNAPSHOT"
implementation("org.json:json:20230227")
implementation("cn.hutool:hutool-http:5.8.26")
implementation("org.apache.httpcomponents:httpclient:4.5.14")

compileOnly("top.mrxiaom:overflow-core-api:$overflow_version")
compileOnly("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.8.0")
compileOnly("top.mrxiaom:overflow-core:$overflow_version")
// testImplementation("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.8.0")

compileOnly(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
}

group = "ltd.guimc.plugin"
version = "0.1.0"

repositories {
if (System.getenv("CI")?.toBoolean() != true) {
maven("https://maven.aliyun.com/repository/public") // 阿里云国内代理仓库
}
maven { url = uri("https://repo.repsy.io/mvn/chrynan/public") }
maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
mavenCentral()
}
Binary file added libs/mirai-hibernate-plugin-2.8.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "mirai-console-plugin-template"
rootProject.name = "mirai-quotly-bot"
91 changes: 0 additions & 91 deletions src/main/java/org/example/mirai/plugin/JavaPluginMain.java

This file was deleted.

118 changes: 0 additions & 118 deletions src/main/kotlin/PluginMain.kt

This file was deleted.

43 changes: 43 additions & 0 deletions src/main/kotlin/ltd/guimc/lgzbot/utils/CooldownUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ltd.guimc.lgzbot.utils

class CooldownUtils(val cooldown: Long) {
var cooldownMap: MutableMap<Any, Long> = mutableMapOf()
var cooldownNoticeMap: MutableMap<Any, Long> = mutableMapOf()

fun flag(target: Any) {
cooldownMap[target] = System.currentTimeMillis()
}

fun isTimePassed(target: Any): Boolean {
return isTimePassed(target, cooldown)
}

fun isTimePassed(target: Any, time: Long): Boolean {
if (cooldownMap.keys.indexOf(target) == -1) return true
if (System.currentTimeMillis() - cooldownMap[target]!! >= time) return true
return false
}

fun shouldSendCooldownNotice(target: Any): Boolean {
if (cooldownNoticeMap.keys.indexOf(target) == -1) return true
if (System.currentTimeMillis() - cooldownNoticeMap[target]!! >= 3000) {
cooldownNoticeMap[target] = System.currentTimeMillis()
return true
}
return false
}

fun getLeftTime(target: Any): Long {
return getLeftTime(target, cooldown)
}

fun getLeftTime(target: Any, time: Long): Long {
if (cooldownMap.keys.indexOf(target) == -1) return -1
return time - (System.currentTimeMillis() - cooldownMap[target]!!)
}

fun addLeftTime(target: Any, time: Long) {
if (cooldownMap.keys.indexOf(target) == -1) return
cooldownMap[target] = cooldownMap[target]!! + time
}
}
Loading

0 comments on commit 65e3196

Please sign in to comment.