Minor cleanup
This commit is contained in:
parent
6894e05610
commit
66ca972b9b
12 changed files with 44 additions and 42 deletions
2
.github/workflows/gradle.yml
vendored
2
.github/workflows/gradle.yml
vendored
|
@ -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: |
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<ID>LongParameterList:Comment.kt$Comment$( channel: String, cmd: String, entry: EntryLink, entryIndex: Int, commentIndex: Int, event: GenericMessageEvent )</ID>
|
||||
<ID>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 )</ID>
|
||||
<ID>LongParameterList:Twitter.kt$Twitter.Companion$( consumerKey: String?, consumerSecret: String?, token: String?, tokenSecret: String?, handle: String?, message: String, isDm: Boolean )</ID>
|
||||
<ID>MagicNumber:ChatGpt.kt$ChatGpt$400</ID>
|
||||
<ID>MagicNumber:ChatGpt.kt$ChatGpt.Companion$200</ID>
|
||||
<ID>MagicNumber:Comment.kt$Comment$3</ID>
|
||||
<ID>MagicNumber:CryptoPrices.kt$CryptoPrices$10</ID>
|
||||
|
@ -48,7 +49,7 @@
|
|||
<ID>MaxLineLength:TwitterOAuth.kt$TwitterOAuth$*</ID>
|
||||
<ID>NestedBlockDepth:Addons.kt$Addons$fun add(command: AbstractCommand): Boolean</ID>
|
||||
<ID>NestedBlockDepth:Addons.kt$Addons$fun add(module: AbstractModule): Boolean</ID>
|
||||
<ID>NestedBlockDepth:ChatGpt.kt$ChatGpt.Companion$@JvmStatic @Throws(ModuleException::class) fun chat(query: String, apiKey: String?): String</ID>
|
||||
<ID>NestedBlockDepth:ChatGpt.kt$ChatGpt.Companion$@JvmStatic @Throws(ModuleException::class) fun chat(query: String, apiKey: String?, maxTokens: Int): String</ID>
|
||||
<ID>NestedBlockDepth:Comment.kt$Comment$override fun commandResponse(channel: String, args: String, event: GenericMessageEvent)</ID>
|
||||
<ID>NestedBlockDepth:CurrencyConverter.kt$CurrencyConverter.Companion$@JvmStatic fun convertCurrency(query: String): Message</ID>
|
||||
<ID>NestedBlockDepth:EntryLink.kt$EntryLink$private fun setTags(tags: List<String?>)</ID>
|
||||
|
@ -64,8 +65,8 @@
|
|||
<ID>NestedBlockDepth:StockQuote.kt$StockQuote.Companion$@JvmStatic @Throws(ModuleException::class) fun getQuote(symbol: String, apiKey: String?): List<Message></ID>
|
||||
<ID>NestedBlockDepth:Tell.kt$Tell$fun send(event: GenericUserEvent)</ID>
|
||||
<ID>NestedBlockDepth:TwitterOAuth.kt$TwitterOAuth$@JvmStatic fun main(args: Array<String>)</ID>
|
||||
<ID>NestedBlockDepth:Utils.kt$Utils$@JvmStatic fun loadData(file: String, default: Any, logger: Logger, description: String): Any</ID>
|
||||
<ID>NestedBlockDepth:Utils.kt$Utils$@JvmStatic fun saveData(file: String, data: Any, logger: Logger, description: String)</ID>
|
||||
<ID>NestedBlockDepth:Utils.kt$Utils$@JvmStatic fun loadSerialData(file: String, default: Any, logger: Logger, description: String): Any</ID>
|
||||
<ID>NestedBlockDepth:Utils.kt$Utils$@JvmStatic fun saveSerialData(file: String, data: Any, logger: Logger, description: String)</ID>
|
||||
<ID>NestedBlockDepth:Weather2.kt$Weather2$override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent)</ID>
|
||||
<ID>NestedBlockDepth:Weather2.kt$Weather2.Companion$@JvmStatic @Throws(ModuleException::class) fun getWeather(query: String, apiKey: String?): List<Message></ID>
|
||||
<ID>PrintStackTrace:TwitterOAuth.kt$TwitterOAuth$ioe</ID>
|
||||
|
@ -76,7 +77,7 @@
|
|||
<ID>SwallowedException:GoogleSearchTest.kt$GoogleSearchTest$e: ModuleException</ID>
|
||||
<ID>SwallowedException:StockQuoteTest.kt$StockQuoteTest$e: ModuleException</ID>
|
||||
<ID>SwallowedException:WolframAlphaTest.kt$WolframAlphaTest$e: ModuleException</ID>
|
||||
<ID>ThrowsCount:ChatGpt.kt$ChatGpt.Companion$@JvmStatic @Throws(ModuleException::class) fun chat(query: String, apiKey: String?): String</ID>
|
||||
<ID>ThrowsCount:ChatGpt.kt$ChatGpt.Companion$@JvmStatic @Throws(ModuleException::class) fun chat(query: String, apiKey: String?, maxTokens: Int): String</ID>
|
||||
<ID>ThrowsCount:GoogleSearch.kt$GoogleSearch.Companion$@JvmStatic @Throws(ModuleException::class) fun searchGoogle( query: String, apiKey: String?, cseKey: String?, quotaUser: String = ReleaseInfo.PROJECT ): List<Message></ID>
|
||||
<ID>ThrowsCount:Joke.kt$Joke.Companion$@JvmStatic @Throws(ModuleException::class) fun randomJoke(): List<Message></ID>
|
||||
<ID>ThrowsCount:Mastodon.kt$Mastodon.Companion$@JvmStatic @Throws(ModuleException::class) fun toot(apiKey: String?, instance: String?, handle: String?, message: String, isDm: Boolean): String</ID>
|
||||
|
|
|
@ -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 <consumerKey> <consumerSecret>
|
||||
#
|
||||
#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
|
||||
|
|
|
@ -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<String>.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 ->
|
||||
|
|
|
@ -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<String, SeenNick>(),
|
||||
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 {
|
||||
|
|
|
@ -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<TellMessage> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return loadData(file, emptyList<TellMessage>(), logger, "message queue") as List<TellMessage>
|
||||
return loadSerialData(file, emptyList<TellMessage>(), logger, "message queue") as List<TellMessage>
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ object TellManager {
|
|||
@JvmStatic
|
||||
fun save(file: String, messages: List<TellMessage?>?) {
|
||||
if (messages != null) {
|
||||
saveData(file, messages, logger, "messages")
|
||||
saveSerialData(file, messages, logger, "messages")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>mobibot</title>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue