Added seen count to info

This commit is contained in:
Erik C. Thauvin 2022-10-02 07:46:50 -07:00
parent c0f5a8bad3
commit ed971a4e7a
6 changed files with 12 additions and 6 deletions

View file

@ -30,7 +30,7 @@ mainClassName = packageName + '.Mobibot'
ext.versions = [
log4j: '2.19.0',
pmd : '6.49.0',
pmd : '6.50.0',
]
repositories {

View file

@ -436,7 +436,7 @@ class Mobibot(nickname: String, val channel: String, logsDirPath: String, p: Pro
addons.add(CurrencyConverter())
addons.add(Dice())
addons.add(GoogleSearch())
addons.add(Info(tell))
addons.add(Info(tell, seen))
addons.add(Joke())
addons.add(Lookup())
addons.add(Ping())

View file

@ -40,13 +40,14 @@ import net.thauvin.erik.mobibot.Utils.plural
import net.thauvin.erik.mobibot.Utils.sendList
import net.thauvin.erik.mobibot.Utils.sendMessage
import net.thauvin.erik.mobibot.commands.links.LinksMgr
import net.thauvin.erik.mobibot.commands.seen.Seen
import net.thauvin.erik.mobibot.commands.tell.Tell
import org.pircbotx.hooks.types.GenericMessageEvent
import java.lang.management.ManagementFactory
import kotlin.time.DurationUnit
import kotlin.time.toDuration
class Info(private val tell: Tell) : AbstractCommand() {
class Info(private val tell: Tell, private val seen: Seen) : AbstractCommand() {
private val allVersions = listOf(
"${ReleaseInfo.PROJECT.capitalise()} ${ReleaseInfo.VERSION} (${ReleaseInfo.WEBSITE.green()})",
"Written by ${ReleaseInfo.AUTHOR} (${ReleaseInfo.AUTHOR_URL.green()})"
@ -107,6 +108,9 @@ class Info(private val tell: Tell) : AbstractCommand() {
.append(ManagementFactory.getRuntimeMXBean().uptime.toUptime())
.append(" [Entries: ")
.append(LinksMgr.entries.links.size)
if (seen.isEnabled()) {
info.append(", Seen: ").append(seen.count())
}
if (isChannelOp(channel, event)) {
if (tell.isEnabled()) {
info.append(", Messages: ").append(tell.size())

View file

@ -101,6 +101,8 @@ class Seen(private val serialObject: String) : AbstractCommand() {
seenNicks.clear()
}
fun count(): Int = seenNicks.size
fun load() {
if (isEnabled()) {
@Suppress("UNCHECKED_CAST")

View file

@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle
#Thu Sep 29 21:38:12 PDT 2022
version.buildmeta=685
#Sun Oct 02 07:45:05 PDT 2022
version.buildmeta=689
version.major=0
version.minor=8
version.patch=0
version.prerelease=rc
version.project=mobibot
version.semver=0.8.0-rc+685
version.semver=0.8.0-rc+689