com.github.stormbit.sdk.example.ExampleUser.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vk-bot-sdk-kotlin Show documentation
Show all versions of vk-bot-sdk-kotlin Show documentation
The Kotlin library for working with VK api
package com.github.stormbit.sdk.example
import com.github.stormbit.sdk.clients.User
import com.github.stormbit.sdk.objects.Captcha
import org.apache.log4j.BasicConfigurator
/**
* Simple echo bot
*/
class ExampleUser {
companion object {
private const val login = "" // Your login
private const val password = "" // Your password
@JvmStatic
fun main(args: Array) {
BasicConfigurator.configure()
// Captcha handler
val captchaHandler = { it: Captcha ->
println("Captcha url: ${it.url}")
print("Code: ")
readLine() ?: ""
}
// Two Factor handler
val twoFactorHandler = {
print("Code: ")
Pair(readLine() ?: "", true)
}
val client = User(login, password, twoFactorListener = twoFactorHandler, captchaListener = captchaHandler)
client.onMessage {
client.sendMessage {
text = it.text
peerId = it.peerId
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy