Added all keyword to seen command
This commit is contained in:
parent
66b8adb743
commit
d8291e2156
7 changed files with 41 additions and 15 deletions
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.8.21" />
|
||||
<option name="version" value="1.8.22" />
|
||||
</component>
|
||||
</project>
|
16
build.gradle
16
build.gradle
|
@ -3,15 +3,15 @@ import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
|
|||
|
||||
plugins {
|
||||
id 'application'
|
||||
id 'com.github.ben-manes.versions' version '0.46.0'
|
||||
id 'com.github.ben-manes.versions' version '0.47.0'
|
||||
id 'idea'
|
||||
id 'io.gitlab.arturbosch.detekt' version '1.22.0'
|
||||
id 'io.gitlab.arturbosch.detekt' version '1.23.0'
|
||||
id 'java'
|
||||
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.8.21'
|
||||
id 'org.jetbrains.kotlin.kapt' version '1.8.21'
|
||||
id 'org.jetbrains.kotlinx.kover' version '0.7.0'
|
||||
id 'org.sonarqube' version '4.0.0.2929'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.8.22'
|
||||
id 'org.jetbrains.kotlin.kapt' version '1.8.22'
|
||||
id 'org.jetbrains.kotlinx.kover' version '0.7.1'
|
||||
id 'org.sonarqube' version '4.2.1.3168'
|
||||
id 'pmd'
|
||||
}
|
||||
|
||||
|
@ -59,11 +59,11 @@ dependencies {
|
|||
|
||||
// Google
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'com.google.guava:guava:31.1-jre'
|
||||
implementation 'com.google.guava:guava:32.0.1-jre'
|
||||
|
||||
// Kotlin
|
||||
implementation platform('org.jetbrains.kotlin:kotlin-bom')
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.5'
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<ID>MagicNumber:Mastodon.kt$Mastodon.Companion$200</ID>
|
||||
<ID>MagicNumber:Mobibot.kt$Mobibot$8</ID>
|
||||
<ID>MagicNumber:Modules.kt$Modules$7</ID>
|
||||
<ID>MagicNumber:Seen.kt$Seen$8</ID>
|
||||
<ID>MagicNumber:SocialManager.kt$SocialManager$1000L</ID>
|
||||
<ID>MagicNumber:SocialManager.kt$SocialManager$60L</ID>
|
||||
<ID>MagicNumber:StockQuote.kt$StockQuote.Companion$10</ID>
|
||||
|
@ -69,6 +70,7 @@
|
|||
<ID>ReturnCount:Addons.kt$Addons$fun exec(channel: String, cmd: String, args: String, event: GenericMessageEvent): Boolean</ID>
|
||||
<ID>ReturnCount:Addons.kt$Addons$fun help(channel: String, topic: String, event: GenericMessageEvent): Boolean</ID>
|
||||
<ID>ReturnCount:ExceptionSanitizer.kt$ExceptionSanitizer$fun ModuleException.sanitize(vararg sanitize: String): ModuleException</ID>
|
||||
<ID>ReturnCount:Seen.kt$Seen$override fun commandResponse(channel: String, args: String, event: GenericMessageEvent)</ID>
|
||||
<ID>SwallowedException:GoogleSearchTest.kt$GoogleSearchTest$e: ModuleException</ID>
|
||||
<ID>SwallowedException:StockQuoteTest.kt$StockQuoteTest$e: ModuleException</ID>
|
||||
<ID>SwallowedException:WolframAlphaTest.kt$WolframAlphaTest$e: ModuleException</ID>
|
||||
|
|
|
@ -32,10 +32,14 @@
|
|||
package net.thauvin.erik.mobibot.commands.seen
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet
|
||||
import net.thauvin.erik.mobibot.Utils
|
||||
import net.thauvin.erik.mobibot.Utils.bold
|
||||
import net.thauvin.erik.mobibot.Utils.bot
|
||||
import net.thauvin.erik.mobibot.Utils.helpFormat
|
||||
import net.thauvin.erik.mobibot.Utils.isChannelOp
|
||||
import net.thauvin.erik.mobibot.Utils.loadSerialData
|
||||
import net.thauvin.erik.mobibot.Utils.saveSerialData
|
||||
import net.thauvin.erik.mobibot.Utils.sendList
|
||||
import net.thauvin.erik.mobibot.Utils.sendMessage
|
||||
import net.thauvin.erik.mobibot.commands.AbstractCommand
|
||||
import net.thauvin.erik.mobibot.commands.Info.Companion.toUptime
|
||||
|
@ -43,15 +47,19 @@ import org.pircbotx.User
|
|||
import org.pircbotx.hooks.types.GenericMessageEvent
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.TreeMap
|
||||
import java.util.*
|
||||
|
||||
|
||||
class Seen(private val serialObject: String) : AbstractCommand() {
|
||||
private val logger: Logger = LoggerFactory.getLogger(Seen::class.java)
|
||||
private val allKeyword = "all"
|
||||
val seenNicks = TreeMap<String, SeenNick>(NickComparator())
|
||||
|
||||
override val name = "seen"
|
||||
override val help = listOf("To view when a nickname was last seen:", helpFormat("%c $name <nick>"))
|
||||
private val helpOp = help.plus(
|
||||
arrayOf("To view all ${"seen".bold()} nicks:", helpFormat("%c $name $allKeyword"))
|
||||
)
|
||||
override val isOpOnly = false
|
||||
override val isPublic = true
|
||||
override val isVisible = true
|
||||
|
@ -61,6 +69,11 @@ class Seen(private val serialObject: String) : AbstractCommand() {
|
|||
if (isEnabled()) {
|
||||
if (args.isNotBlank() && !args.contains(' ')) {
|
||||
val ch = event.bot().userChannelDao.getChannel(channel)
|
||||
if (args.equals(allKeyword) && ch.isOp(event.user) && seenNicks.isNotEmpty()) {
|
||||
event.sendMessage("The ${"seen".bold()} nicks are:")
|
||||
event.sendList(seenNicks.keys.toList(), 8, separator = ", ", isIndent = true)
|
||||
return
|
||||
}
|
||||
ch.users.forEach {
|
||||
if (args.equals(it.nick, true)) {
|
||||
event.sendMessage("${it.nick} is on ${channel}.")
|
||||
|
@ -102,6 +115,17 @@ class Seen(private val serialObject: String) : AbstractCommand() {
|
|||
|
||||
fun count(): Int = seenNicks.size
|
||||
|
||||
override fun helpResponse(channel: String, topic: String, event: GenericMessageEvent): Boolean {
|
||||
return if (event.isChannelOp(channel)) {
|
||||
for (h in helpOp) {
|
||||
event.sendMessage(Utils.helpCmdSyntax(h, event.bot().nick, true))
|
||||
}
|
||||
true
|
||||
} else {
|
||||
super.helpResponse(channel, topic, event)
|
||||
}
|
||||
}
|
||||
|
||||
fun load() {
|
||||
if (isEnabled()) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
|
|
@ -46,6 +46,6 @@ data class EntryComment(var comment: String, var nick: String) : Serializable {
|
|||
|
||||
companion object {
|
||||
// Serial version UID
|
||||
const val serialVersionUID = 1L
|
||||
private const val serialVersionUID: Long = 1L
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,6 +208,6 @@ class EntryLink(
|
|||
|
||||
companion object {
|
||||
// Serial version UID
|
||||
const val serialVersionUID = 1L
|
||||
private const val serialVersionUID: Long = 1L
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#Generated by the Semver Plugin for Gradle
|
||||
#Tue May 23 08:26:47 PDT 2023
|
||||
version.buildmeta=1087
|
||||
#Sat Jun 17 21:28:53 PDT 2023
|
||||
version.buildmeta=1098
|
||||
version.major=0
|
||||
version.minor=8
|
||||
version.patch=0
|
||||
version.prerelease=rc
|
||||
version.project=mobibot
|
||||
version.semver=0.8.0-rc+1087
|
||||
version.semver=0.8.0-rc+1098
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue