-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from InsanusMokrassar/13.0.0
13.0.0
- Loading branch information
Showing
7 changed files
with
169 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# CustomBot | ||
|
||
This bot basically have no any useful behaviour, but you may customize it as a playground | ||
|
||
## Launch | ||
|
||
```bash | ||
../gradlew run --args="BOT_TOKEN" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
apply plugin: 'kotlin' | ||
apply plugin: 'application' | ||
|
||
mainClassName="CustomBotKt" | ||
|
||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
|
||
implementation "dev.inmo:tgbotapi:$telegram_bot_api_version" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import dev.inmo.kslog.common.KSLog | ||
import dev.inmo.kslog.common.LogLevel | ||
import dev.inmo.kslog.common.defaultMessageFormatter | ||
import dev.inmo.kslog.common.setDefaultKSLog | ||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions | ||
import dev.inmo.tgbotapi.extensions.api.bot.getMe | ||
import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling | ||
import dev.inmo.tgbotapi.utils.PreviewFeature | ||
import kotlinx.coroutines.* | ||
|
||
/** | ||
* The main purpose of this bot is just to answer "Oh, hi, " and add user mention here | ||
*/ | ||
@OptIn(PreviewFeature::class) | ||
suspend fun main(vararg args: String) { | ||
val botToken = args.first() | ||
|
||
val isDebug = args.any { it == "debug" } | ||
|
||
if (isDebug) { | ||
setDefaultKSLog( | ||
KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? -> | ||
println(defaultMessageFormatter(level, tag, message, throwable)) | ||
} | ||
) | ||
} | ||
|
||
telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope(Dispatchers.IO)) { | ||
val me = getMe() | ||
|
||
allUpdatesFlow.subscribeSafelyWithoutExceptions(this) { println(it) } | ||
}.second.join() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,5 @@ include ":LinkPreviewsBot" | |
include ":BoostsInfoBot" | ||
|
||
include ":BusinessConnectionsBot" | ||
|
||
include ":CustomBot" |