diff --git a/.idea/misc.xml b/.idea/misc.xml index d755e4c..1503b42 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/build.gradle b/build.gradle index fdee3ae..11e2a93 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'application' id 'com.github.ben-manes.versions' version '0.39.0' id 'idea' - id 'io.gitlab.arturbosch.detekt' version '1.18.0' + id 'io.gitlab.arturbosch.detekt' version '1.18.1' id 'jacoco' id 'java' id 'net.thauvin.erik.gradle.semver' version '1.0.4' @@ -39,7 +39,7 @@ dependencies { compileOnly 'pircbot:pircbot:1.5.0:sources' implementation(platform("org.jetbrains.kotlin:kotlin-bom")) - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2' implementation "org.apache.logging.log4j:log4j-api:$versions.log4j" implementation "org.apache.logging.log4j:log4j-core:$versions.log4j" @@ -97,6 +97,7 @@ kotlin { } kapt { + includeCompileClasspath = false arguments { arg('semver.project.dir', projectDir) } diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/PinboardUtils.kt b/src/main/kotlin/net/thauvin/erik/mobibot/PinboardUtils.kt index 019d152..d3408af 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/PinboardUtils.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/PinboardUtils.kt @@ -32,6 +32,7 @@ package net.thauvin.erik.mobibot +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext @@ -47,12 +48,14 @@ import java.util.Date * Handles posts to pinboard.in. */ object PinboardUtils { + private val dispatcher: CoroutineDispatcher = Dispatchers.IO + /** * Adds a pin. */ @JvmStatic fun addPin(poster: PinboardPoster, ircServer: String, entry: EntryLink) = runBlocking { - withContext(Dispatchers.Default) { + withContext(dispatcher) { poster.addPin( entry.link, entry.title, @@ -68,7 +71,7 @@ object PinboardUtils { */ @JvmStatic fun deletePin(poster: PinboardPoster, entry: EntryLink) = runBlocking { - withContext(Dispatchers.Default) { + withContext(dispatcher) { poster.deletePin(entry.link) } } @@ -78,7 +81,7 @@ object PinboardUtils { */ @JvmStatic fun updatePin(poster: PinboardPoster, ircServer: String, oldUrl: String, entry: EntryLink) = runBlocking { - withContext(Dispatchers.Default) { + withContext(dispatcher) { with(entry) { if (oldUrl != link) { poster.deletePin(oldUrl) diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/ThreadedModule.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/ThreadedModule.kt index 44a5e24..e382ac5 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/ThreadedModule.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/ThreadedModule.kt @@ -31,6 +31,8 @@ */ package net.thauvin.erik.mobibot.modules +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking import net.thauvin.erik.mobibot.Mobibot /** @@ -44,7 +46,11 @@ abstract class ThreadedModule(bot: Mobibot) : AbstractModule(bot) { isPrivate: Boolean ) { if (isEnabled && args.isNotEmpty()) { - Thread { run(sender, cmd, args, isPrivate) }.start() + runBlocking { + launch { + run(sender, cmd, args, isPrivate) + } + } } else { helpResponse(sender, isPrivate) } diff --git a/version.properties b/version.properties index 50f350f..d4b938a 100644 --- a/version.properties +++ b/version.properties @@ -1,9 +1,9 @@ #Generated by the Semver Plugin for Gradle -#Tue Aug 24 11:34:08 PDT 2021 -version.buildmeta=1366 +#Wed Sep 15 13:00:35 PDT 2021 +version.buildmeta=1390 version.major=0 version.minor=8 version.patch=0 version.prerelease=beta version.project=mobibot -version.semver=0.8.0-beta+1366 +version.semver=0.8.0-beta+1390