All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.stormbit.sdk.example.ExampleUser.kt Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
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