7 Commits

Author SHA1 Message Date
Wieland Schöbl
e773419986 Add cli rework 2021-06-03 14:40:06 +02:00
Wieland Schöbl
4e2186026c Revert "hotfix 1"
This reverts commit 1f3ebc42
2021-06-02 23:21:50 +02:00
Wieland Schöbl
7ff789afd3 Revert "temporarily removed inactive servers message"
This reverts commit 3d73d50a47.

# Conflicts:
#	src/main/kotlin/org/hmcore/Channels.kt
2021-06-02 23:20:52 +02:00
Wieland Schöbl
c9acfdc79e Revert "hotfix 1"
This reverts commit 1f3ebc42
2021-06-02 23:19:46 +02:00
UnrealValentin
3d73d50a47 temporarily removed inactive servers message 2021-06-02 23:04:29 +02:00
UnrealValentin
e6eaabaa1a Merge branch 'master' of https://github.com/HMCore/BlogShot 2021-06-02 22:58:59 +02:00
UnrealValentin
1f3ebc42e6 hotfix 1 2021-06-02 22:58:54 +02:00
7 changed files with 66 additions and 0 deletions

View File

@@ -23,6 +23,8 @@ dependencies {
implementation 'org.jsoup:jsoup:1.13.1'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.1'
implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.2'
implementation 'com.github.redouane59.twitter:twittered:1.20'
implementation group: 'org.quartz-scheduler', name: 'quartz', version: '2.3.2'

View File

@@ -1,5 +1,6 @@
package org.hmcore
import kotlinx.cli.ArgParser
import org.hmcore.web.fakeUpdateBlogPost
import org.hmcore.web.fakeUpdateJobListings
import net.dv8tion.jda.api.hooks.ListenerAdapter
@@ -12,6 +13,7 @@ class AdminCli : ListenerAdapter() {
val prefix = "!"
override fun onPrivateMessageReceived(event: PrivateMessageReceivedEvent) {
val msg = event.message.contentRaw
if (event.author.idLong != Admin.userId ||
!msg.startsWith(prefix)

View File

@@ -92,6 +92,9 @@ object Main {
getNewJobListings()?.forEach {
Channels.sentToAll(MessageBuilder().setEmbed(it.toMessageEmbed()).build(), MessageType.JOB_LISTING)
}
getNewJobListings()?.forEach {
}
}
val scheduler = StdSchedulerFactory.getDefaultScheduler()

View File

@@ -0,0 +1,4 @@
package org.hmcore.cli
class Commands {
}

View File

@@ -0,0 +1,29 @@
@file:OptIn(ExperimentalCli::class)
package org.hmcore.cli.admin
import kotlinx.cli.ArgType
import kotlinx.cli.ExperimentalCli
import kotlinx.cli.Subcommand
import kotlinx.cli.optional
import org.hmcore.TwitterJob
import org.hmcore.web.fakeUpdateBlogPost
import org.hmcore.web.fakeUpdateJobListings
class FakeUpdateCommand : Subcommand("fakeUpdate", "Cause a fake update. Use with great caution.") {
private val twitter by option(ArgType.Boolean,
"twitter",
"Cause a fake update for Twitter")
private val jobs by argument(ArgType.Int,
"jobs",
"Cause a fake update for Job Listings for the x amount of last jobs").optional()
private val blog by argument(ArgType.Int,
"blogs",
"Cause a fake update for Blogs for the x amount of last blogs").optional()
override fun execute() {
blog?.let { fakeUpdateBlogPost(it) }
jobs?.let { fakeUpdateJobListings(it) }
if (twitter == true) TwitterJob.lastTweetID = "empty"
}
}

View File

@@ -0,0 +1,13 @@
@file:OptIn(ExperimentalCli::class)
package org.hmcore.cli.admin
import kotlinx.cli.ExperimentalCli
import kotlinx.cli.Subcommand
import org.hmcore.Admin
class InfoCommand : Subcommand("info", "Print an overview of all servers") {
override fun execute() {
Admin.info()
}
}

View File

@@ -0,0 +1,13 @@
@file:OptIn(ExperimentalCli::class)
package org.hmcore.cli.admin
import kotlinx.cli.ExperimentalCli
import kotlinx.cli.Subcommand
import kotlin.system.exitProcess
class StopCommand : Subcommand("stop", "Stop the bot") {
override fun execute() {
exitProcess(1)
}
}