diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 4a41aff..94687dc 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -68,7 +68,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- run: ./gradlew sonarqube
+ run: ./gradlew sonar
- name: Cleanup Gradle Cache
run: |
diff --git a/README.md b/README.md
index 2459b1b..4dee7b5 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
# mobibot
-[](https://opensource.org/licenses/BSD-3-Clause) [](https://sonarcloud.io/summary/new_code?id=ethauvin_mobibot)
-
-[](https://github.com/ethauvin/mobibot/actions/workflows/gradle.yml) [](https://circleci.com/gh/ethauvin/mobibot/tree/master)
+[](https://opensource.org/licenses/BSD-3-Clause)
+[](https://kotlinlang.org/)
+[](https://sonarcloud.io/summary/new_code?id=ethauvin_mobibot)
+[](https://github.com/ethauvin/mobibot/actions/workflows/gradle.yml)
+[](https://circleci.com/gh/ethauvin/mobibot/tree/master)
Some very basic instructions:
diff --git a/build.gradle b/build.gradle
index 178326f..3515d31 100644
--- a/build.gradle
+++ b/build.gradle
@@ -55,7 +55,7 @@ dependencies {
implementation 'commons-net:commons-net:3.9.0'
// Google
- implementation 'com.google.code.gson:gson:2.10'
+ implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.guava:guava:31.1-jre'
// Kotlin
@@ -82,7 +82,7 @@ dependencies {
implementation 'net.thauvin.erik:cryptoprice:1.0.0'
implementation 'net.thauvin.erik:jokeapi:0.9-SNAPSHOT'
implementation 'net.thauvin.erik:pinboard-poster:1.0.3'
- implementation 'net.thauvin.erik:urlencoder:1.0.1'
+ implementation 'net.thauvin.erik:urlencoder:1.3.0'
testImplementation 'com.willowtreeapps.assertk:assertk-jvm:0.25'
// testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
@@ -188,7 +188,7 @@ sonarqube {
}
}
-tasks.sonarqube {
+tasks.sonar {
dependsOn 'koverReport'
}
@@ -219,6 +219,6 @@ task deploy {
task release {
group = 'Publishing'
description = 'Releases new version.'
- dependsOn(clean, wrapper, check, deploy)
+ dependsOn(clean, check, deploy)
mustRunAfter clean
}
diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml
index 19b4dbd..57c71a4 100644
--- a/config/detekt/baseline.xml
+++ b/config/detekt/baseline.xml
@@ -11,6 +11,7 @@
LongParameterList:Comment.kt$Comment$( channel: String, cmd: String, entry: EntryLink, entryIndex: Int, commentIndex: Int, event: GenericMessageEvent )
LongParameterList:EntryLink.kt$EntryLink$( // Link's comments val comments: MutableList<EntryComment> = mutableListOf(), // Tags/categories val tags: MutableList<SyndCategory> = mutableListOf(), // Channel var channel: String, // Creation date var date: Date = Calendar.getInstance().time, // Link's URL var link: String, // Author's login var login: String = "", // Author's nickname var nick: String, // Link's title var title: String )
LongParameterList:Twitter.kt$Twitter.Companion$( consumerKey: String?, consumerSecret: String?, token: String?, tokenSecret: String?, handle: String?, message: String, isDm: Boolean )
+ MagicNumber:ChatGpt.kt$ChatGpt$400
MagicNumber:ChatGpt.kt$ChatGpt.Companion$200
MagicNumber:Comment.kt$Comment$3
MagicNumber:CryptoPrices.kt$CryptoPrices$10
@@ -48,7 +49,7 @@
MaxLineLength:TwitterOAuth.kt$TwitterOAuth$*
NestedBlockDepth:Addons.kt$Addons$fun add(command: AbstractCommand): Boolean
NestedBlockDepth:Addons.kt$Addons$fun add(module: AbstractModule): Boolean
- NestedBlockDepth:ChatGpt.kt$ChatGpt.Companion$@JvmStatic @Throws(ModuleException::class) fun chat(query: String, apiKey: String?): String
+ NestedBlockDepth:ChatGpt.kt$ChatGpt.Companion$@JvmStatic @Throws(ModuleException::class) fun chat(query: String, apiKey: String?, maxTokens: Int): String
NestedBlockDepth:Comment.kt$Comment$override fun commandResponse(channel: String, args: String, event: GenericMessageEvent)
NestedBlockDepth:CurrencyConverter.kt$CurrencyConverter.Companion$@JvmStatic fun convertCurrency(query: String): Message
NestedBlockDepth:EntryLink.kt$EntryLink$private fun setTags(tags: List<String?>)
@@ -64,8 +65,8 @@
NestedBlockDepth:StockQuote.kt$StockQuote.Companion$@JvmStatic @Throws(ModuleException::class) fun getQuote(symbol: String, apiKey: String?): List<Message>
NestedBlockDepth:Tell.kt$Tell$fun send(event: GenericUserEvent)
NestedBlockDepth:TwitterOAuth.kt$TwitterOAuth$@JvmStatic fun main(args: Array<String>)
- NestedBlockDepth:Utils.kt$Utils$@JvmStatic fun loadData(file: String, default: Any, logger: Logger, description: String): Any
- NestedBlockDepth:Utils.kt$Utils$@JvmStatic fun saveData(file: String, data: Any, logger: Logger, description: String)
+ NestedBlockDepth:Utils.kt$Utils$@JvmStatic fun loadSerialData(file: String, default: Any, logger: Logger, description: String): Any
+ NestedBlockDepth:Utils.kt$Utils$@JvmStatic fun saveSerialData(file: String, data: Any, logger: Logger, description: String)
NestedBlockDepth:Weather2.kt$Weather2$override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent)
NestedBlockDepth:Weather2.kt$Weather2.Companion$@JvmStatic @Throws(ModuleException::class) fun getWeather(query: String, apiKey: String?): List<Message>
PrintStackTrace:TwitterOAuth.kt$TwitterOAuth$ioe
@@ -76,7 +77,7 @@
SwallowedException:GoogleSearchTest.kt$GoogleSearchTest$e: ModuleException
SwallowedException:StockQuoteTest.kt$StockQuoteTest$e: ModuleException
SwallowedException:WolframAlphaTest.kt$WolframAlphaTest$e: ModuleException
- ThrowsCount:ChatGpt.kt$ChatGpt.Companion$@JvmStatic @Throws(ModuleException::class) fun chat(query: String, apiKey: String?): String
+ ThrowsCount:ChatGpt.kt$ChatGpt.Companion$@JvmStatic @Throws(ModuleException::class) fun chat(query: String, apiKey: String?, maxTokens: Int): String
ThrowsCount:GoogleSearch.kt$GoogleSearch.Companion$@JvmStatic @Throws(ModuleException::class) fun searchGoogle( query: String, apiKey: String?, cseKey: String?, quotaUser: String = ReleaseInfo.PROJECT ): List<Message>
ThrowsCount:Joke.kt$Joke.Companion$@JvmStatic @Throws(ModuleException::class) fun randomJoke(): List<Message>
ThrowsCount:Mastodon.kt$Mastodon.Companion$@JvmStatic @Throws(ModuleException::class) fun toot(apiKey: String?, instance: String?, handle: String?, message: String, isDm: Boolean): String
diff --git a/properties/mobibot.properties b/properties/mobibot.properties
index 5551173..e82910c 100644
--- a/properties/mobibot.properties
+++ b/properties/mobibot.properties
@@ -28,12 +28,12 @@ tell-max-size=50
#disabled-modules=dice, joke
#
-# Credentials for: http://pinboard.in/
+# API Token for: https://pinboard.in/settings/password
#
#pinboard-api-token=user\:TOKEN
#
-# Configure app at: https://developer.twitter.com/en/apps
+# Configure app at: https://developer.twitter.com/
# and then: java -cp mobibot.jar net.thauvin.erik.mobibot.TwitterOAuth
#
#twitter-consumerKey=
@@ -61,14 +61,14 @@ tell-max-size=50
#mastodon-auto-post=true
#
-# Create custom search engine at: https://cse.google.com/
-# and get API key from: https://console.developers.google.com/
+# Create custom search engine at: https://programmablesearchengine.google.com/
+# and get API key from: https://console.cloud.google.com/apis
#
#google-api=
#google-cse-cx=
#
-# Get OpenWeatherMap API key from: https://openweathermap.org/
+# Get OpenWeatherMap API key from: https://openweathermap.org/api
#
#owm-api-key=
@@ -87,3 +87,4 @@ tell-max-size=50
# ChatGPT/OpenAI API key from: https://beta.openai.com/account/api-keys
#
#chatgpt-api-key=
+#chatgpt-max-tokens=1024
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt b/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
index bc9860d..359de74 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/Utils.kt
@@ -47,7 +47,6 @@ import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.net.HttpURLConnection
import java.net.URL
-import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Paths
import java.time.LocalDateTime
@@ -189,7 +188,7 @@ object Utils {
}
/**
- * Returns {@code true} if the specified user is an operator on the [channel].
+ * Returns `true` if the specified user is an operator on the [channel].
*/
@JvmStatic
fun GenericMessageEvent.isChannelOp(channel: String): Boolean {
@@ -197,7 +196,7 @@ object Utils {
}
/**
- * Returns {@code true} if a HTTP status code indicates a successful response.
+ * Returns `true` if a HTTP status code indicates a successful response.
*/
@JvmStatic
fun Int.isHttpSuccess() = this in 200..399
@@ -214,10 +213,10 @@ object Utils {
}
/**
- * Load data.
+ * Load serial data from file.
*/
@JvmStatic
- fun loadData(file: String, default: Any, logger: Logger, description: String): Any {
+ fun loadSerialData(file: String, default: Any, logger: Logger, description: String): Any {
val serialFile = Paths.get(file)
if (serialFile.exists() && serialFile.fileSize() > 0) {
try {
@@ -237,7 +236,7 @@ object Utils {
}
/**
- * Returns {@code true} if the list does not contain the given string.
+ * Returns `true` if the list does not contain the given string.
*/
@JvmStatic
fun List.notContains(text: String, ignoreCase: Boolean = false) = this.none { it.equals(text, ignoreCase) }
@@ -290,7 +289,7 @@ object Utils {
* Save data
*/
@JvmStatic
- fun saveData(file: String, data: Any, logger: Logger, description: String) {
+ fun saveSerialData(file: String, data: Any, logger: Logger, description: String) {
try {
BufferedOutputStream(Files.newOutputStream(Paths.get(file))).use { bos ->
ObjectOutputStream(bos).use { output ->
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/seen/Seen.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/seen/Seen.kt
index 66a3259..2b97f5a 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/seen/Seen.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/seen/Seen.kt
@@ -35,8 +35,8 @@ package net.thauvin.erik.mobibot.commands.seen
import com.google.common.collect.ImmutableSortedSet
import net.thauvin.erik.mobibot.Utils.bot
import net.thauvin.erik.mobibot.Utils.helpFormat
-import net.thauvin.erik.mobibot.Utils.loadData
-import net.thauvin.erik.mobibot.Utils.saveData
+import net.thauvin.erik.mobibot.Utils.loadSerialData
+import net.thauvin.erik.mobibot.Utils.saveSerialData
import net.thauvin.erik.mobibot.Utils.sendMessage
import net.thauvin.erik.mobibot.commands.AbstractCommand
import net.thauvin.erik.mobibot.commands.Info.Companion.toUptime
@@ -107,7 +107,7 @@ class Seen(private val serialObject: String) : AbstractCommand() {
if (isEnabled()) {
@Suppress("UNCHECKED_CAST")
seenNicks.putAll(
- loadData(
+ loadSerialData(
serialObject,
TreeMap(),
logger,
@@ -118,7 +118,7 @@ class Seen(private val serialObject: String) : AbstractCommand() {
}
fun save() {
- saveData(serialObject, seenNicks, logger, "seen nicknames")
+ saveSerialData(serialObject, seenNicks, logger, "seen nicknames")
}
init {
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellManager.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellManager.kt
index 3c1f6b5..74ed301 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellManager.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellManager.kt
@@ -31,8 +31,8 @@
*/
package net.thauvin.erik.mobibot.commands.tell
-import net.thauvin.erik.mobibot.Utils.loadData
-import net.thauvin.erik.mobibot.Utils.saveData
+import net.thauvin.erik.mobibot.Utils.loadSerialData
+import net.thauvin.erik.mobibot.Utils.saveSerialData
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.time.Clock
@@ -60,7 +60,7 @@ object TellManager {
@JvmStatic
fun load(file: String): List {
@Suppress("UNCHECKED_CAST")
- return loadData(file, emptyList(), logger, "message queue") as List
+ return loadSerialData(file, emptyList(), logger, "message queue") as List
}
/**
@@ -69,7 +69,7 @@ object TellManager {
@JvmStatic
fun save(file: String, messages: List?) {
if (messages != null) {
- saveData(file, messages, logger, "messages")
+ saveSerialData(file, messages, logger, "messages")
}
}
}
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessage.kt b/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessage.kt
index 7d8aaed..c9333c9 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessage.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessage.kt
@@ -66,12 +66,12 @@ class TellMessage(
var id: String = queued.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
/**
- * Returns {@code true} if a notification was sent.
+ * Returns `true` if a notification was sent.
*/
var isNotified = false
/**
- * Returns {@code true} if the message was received.
+ * Returns `true` if the message was received.
*/
var isReceived = false
set(value) {
diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntryLink.kt b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntryLink.kt
index 59f4e73..ab0fee4 100644
--- a/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntryLink.kt
+++ b/src/main/kotlin/net/thauvin/erik/mobibot/entries/EntryLink.kt
@@ -130,8 +130,8 @@ class EntryLink(
/**
* Formats the tags.
*/
- fun formatTags(sep: String, prefix: String = "") : String {
- return tags.joinToString(separator = sep, prefix = prefix){it.name}
+ fun formatTags(sep: String, prefix: String = ""): String {
+ return tags.joinToString(separator = sep, prefix = prefix) { it.name }
}
/**
diff --git a/version.properties b/version.properties
index c234d1f..c049177 100644
--- a/version.properties
+++ b/version.properties
@@ -1,9 +1,9 @@
#Generated by the Semver Plugin for Gradle
-#Thu Jan 05 16:20:43 PST 2023
-version.buildmeta=948
+#Thu Jan 12 00:57:56 PST 2023
+version.buildmeta=975
version.major=0
version.minor=8
version.patch=0
version.prerelease=rc
version.project=mobibot
-version.semver=0.8.0-rc+948
+version.semver=0.8.0-rc+975
diff --git a/website/index.html b/website/index.html
index 2d134f2..ea78552 100644
--- a/website/index.html
+++ b/website/index.html
@@ -1,6 +1,5 @@
-
-
+
+
mobibot