Skip to content

Commit

Permalink
Merge pull request #35 from DreamExposure/develop
Browse files Browse the repository at this point in the history
v2.1.1 RC
  • Loading branch information
NovaFox161 authored Sep 13, 2024
2 parents 5155465 + 947b499 commit ed98e0b
Show file tree
Hide file tree
Showing 84 changed files with 1,667 additions and 963 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,27 @@ on:

jobs:
build:
name: Build for JDK ${{ matrix.java }}
name: Build for JDK 17
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'DreamExposure/TicketBird-Discord-Bot' }}
strategy:
matrix:
java: [ 17, 20 ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
java-version: 17
distribution: 'adopt'

- name: Validate gradle
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2

- name: Change wrapper permissions
run: chmod +x ./gradlew
Expand All @@ -46,19 +43,19 @@ jobs:
if: ${{ github.event_name != 'pull_request' && (github.ref_name == 'develop' || github.ref_name == 'master') }}
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'adopt'
Expand All @@ -72,8 +69,8 @@ jobs:
SCW_USER: ${{ secrets.SCW_USER }}
SCW_SECRET: ${{ secrets.SCW_SECRET }}
with:
command: ./gradlew jib -Djib.to.auth.username=${SCW_USER} -Djib.to.auth.password=${SCW_SECRET}
attempt_limit: 5
command: ./gradlew jib -Djib.to.auth.username=${SCW_USER} -Djib.to.auth.password=${SCW_SECRET} -Djib.console=plain
attempt_limit: 25
# 1 minute in ms
attempt_delay: 60000
deploy-dev:
Expand All @@ -82,7 +79,7 @@ jobs:
if: github.ref_name == 'develop'
needs: publish-artifacts
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Perfect for modmail, community management, and more, TicketBird is capable of al

# 💎 Core Features
- Simple setup (just use one command to get everything initiated)
- Now with customizable messages!
- Easy to repair. Accidentally delete a channel? No worries, TicketBird is always watching for changes and ready to repair itself via a single command!
- Easy for users to understand and use without a single command (but can also open tickets with a command)
- Allow users to pick from up to 25 topics (called projects), if desired
Expand All @@ -39,6 +40,7 @@ Perfect for modmail, community management, and more, TicketBird is capable of al
| /setup language | Allows you to select the language for the bot to use | Admin-only |
| /setup use-projects | Whether to use "projects" or ticket topics to help sort tickets | Admin-only |
| /setup show-ticket-stats | Whether to show opened/closed ticket stats in the support request embed | Admin-only |
| /setup messaging | Allows configuring certain messages found throughout TicketBird | Admin-only |
| /setup timing | Allows configuring the timing of TicketBird's automated actions | Admin-only |
| /setup ping | Allows modifying the default ping setting when a new ticket is opened | Admin-only |
| /setup logging | Allows enabling and configuring ticket logging | Admin-only |
Expand All @@ -52,6 +54,7 @@ Perfect for modmail, community management, and more, TicketBird is capable of al
| /project list | Lists all existing projects/topics | Admin-only |
| /project view | View full details about a specific project/topic | Admin-only |
| /project edit | Edit various settings for a project/topic - Like changing prefix, staff, or ping override | Admin-only |
| /project edit-info | Edit the additional info within a project | Admin-only |
| /ticket open | Opens a new ticket | Everyone |
| /ticket topic | Changes a ticket's topic when run in a ticket channel | Everyone |
| /ticket add | Adds a user to the ticket as a participant when run in a ticket channel | Everyone |
Expand All @@ -63,7 +66,7 @@ Perfect for modmail, community management, and more, TicketBird is capable of al
# 🗓️ Planned & Work In Progress
This bot is a hobby project for me, please note that while these features are planned, there's no solid timeline.
- Website rewrite (It's old and ugly)
- Customizable messages
- [WIP] Customizable messages
- And so much more!

# 🧰 Tech stack
Expand Down
44 changes: 24 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import com.squareup.kotlinpoet.FileSpec
import com.squareup.kotlinpoet.PropertySpec
import com.squareup.kotlinpoet.TypeSpec
Expand All @@ -7,35 +6,34 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
// Kotlin
kotlin("jvm") version "1.9.10"
kotlin("jvm") version "2.0.20"

// Spring
kotlin("plugin.spring") version "1.9.10"
id("org.springframework.boot") version "3.1.3"
id("io.spring.dependency-management") version "1.1.3"
kotlin("plugin.spring") version "2.0.20"
id("org.springframework.boot") version "3.3.3"
id("io.spring.dependency-management") version "1.1.6"

// Tooling
id("com.gorylenko.gradle-git-properties") version "2.4.1"
id("com.google.cloud.tools.jib") version "3.4.0"
id("com.gorylenko.gradle-git-properties") version "2.4.2"
id("com.google.cloud.tools.jib") version "3.4.3"
}

buildscript {
dependencies {
classpath("com.squareup:kotlinpoet:1.14.2")
classpath("com.squareup:kotlinpoet:1.18.1")
}
}

val ticketBirdVersion = "2.1.0"
val gradleWrapperVersion = "7.6"
val ticketBirdVersion = "2.1.1"
val gradleWrapperVersion = "8.10"
val javaVersion = "17"
val d4jVersion = "3.2.6"
val d4jStoresVersion = "3.2.2"
val logbackContribVersion = "0.1.5"
val mysqlR2dbcVersion = "0.8.2.RELEASE"
val mySqlConnectorVersion = "8.0.33"
val discordWebhooksVersion = "0.8.4"
val springMockkVersion = "4.0.2"
val commonsIOVersion = "2.13.0"
val orgJsonVersion = "20240303"
val commonsIOVersion = "2.15.1"

group = "org.dreamexposure"
version = ticketBirdVersion
Expand All @@ -45,7 +43,7 @@ val buildVersion = if (System.getenv("GITHUB_RUN_NUMBER") != null) {
} else {
"$version.d${System.currentTimeMillis().div(1000)}" //Seconds since epoch
}
val kotlinSrcDir: File = buildDir.resolve("src/main/kotlin")
val kotlinSrcDir = layout.buildDirectory.dir("src/main/kotlin").map(Directory::getAsFile).get()

java {
sourceCompatibility = JavaVersion.toVersion(javaVersion)
Expand Down Expand Up @@ -96,18 +94,22 @@ dependencies {
// Database
implementation("org.flywaydb:flyway-core")
implementation("org.flywaydb:flyway-mysql")
implementation("dev.miku:r2dbc-mysql:$mysqlR2dbcVersion")
implementation("mysql:mysql-connector-java:$mySqlConnectorVersion")
implementation("io.asyncer:r2dbc-mysql:1.3.0") // TODO: Remove hard coded version once spring includes this in bom as it is a breaking change
implementation("com.mysql:mysql-connector-j")

// IO
implementation("org.json:json:$orgJsonVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("commons-io:commons-io:$commonsIOVersion")

// Discord
implementation("com.discord4j:discord4j-core:$d4jVersion")
implementation("com.discord4j:stores-redis:$d4jStoresVersion")
implementation("club.minnced:discord-webhooks:$discordWebhooksVersion")
implementation("club.minnced:discord-webhooks:$discordWebhooksVersion") {
// Due to vulnerability in older versions: https://github.com/advisories/GHSA-rm7j-f5g5-27vv
exclude(group = "org.json", module = "json")
}

// Test
testImplementation("org.springframework.boot:spring-boot-starter-test") {
Expand All @@ -123,10 +125,10 @@ dependencies {
jib {
to {
image = "rg.nl-ams.scw.cloud/dreamexposure/ticketbird"
tags = mutableSetOf("latest", ticketBirdVersion, buildVersion)
tags = mutableSetOf("latest", buildVersion)
}

from.image = "eclipse-temurin:17-jre-alpine"
from.image = "eclipse-temurin:17-jre-alpine@sha256:03756521d6d21e52cd72793179b8d316be1b3d1ba362ed9ee659687d5c073a63"
}

gitProperties {
Expand All @@ -141,7 +143,7 @@ tasks {
doLast {
@Suppress("UNCHECKED_CAST")
val gitProperties = ext[gitProperties.extProperty] as Map<String, String>
val enumPairs = gitProperties.mapKeys { it.key.replace('.', '_').toUpperCase() }
val enumPairs = gitProperties.mapKeys { it.key.replace('.', '_').uppercase() }

val enumBuilder = TypeSpec.enumBuilder("GitProperty")
.primaryConstructor(
Expand Down Expand Up @@ -175,6 +177,8 @@ tasks {
withType<KotlinCompile> {
dependsOn(generateGitProperties)

@Suppress("DEPRECATION")
// FIXME: This is marked as deprecated but the related link does not seem to work, and no quick fix is available
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = java.targetCompatibility.majorVersion
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
34 changes: 21 additions & 13 deletions gradlew
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,10 +85,9 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +134,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +201,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Loading

0 comments on commit ed98e0b

Please sign in to comment.