Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Last active February 16, 2016 08:34
Show Gist options
  • Select an option

  • Save masahitojp/bae693042214abb9e80c to your computer and use it in GitHub Desktop.

Select an option

Save masahitojp/bae693042214abb9e80c to your computer and use it in GitHub Desktop.
botan handler for Kotlin v1.0.0
apply plugin: 'kotlin'
apply plugin: 'application'
buildscript {
ext.kotlin_version = '1.0.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
mainClassName = 'com.github.masahitojp.botan.Botan'
defaultTasks 'run'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.github.masahitojp:botan-core:0.5.0.0'
}
import com.github.masahitojp.botan.Botan
import com.github.masahitojp.botan.adapter.ComandLineAdapter
fun main(args: Array<String>) {
Botan.BotanBuilder()
.setAdapter(ComandLineAdapter())
.build()
.start();
}
package handlers
import com.github.masahitojp.botan.Robot
import com.github.masahitojp.botan.handler.BotanMessageHandlers
import com.github.masahitojp.botan.message.BotanMessage
class PingHandlers : BotanMessageHandlers {
override fun register(robot: Robot?) {
robot?.respond(
"ping\\z",
"ping method",
{m: BotanMessage -> m.reply("pong")}
)
robot?.router?.GET("/", {req, res -> "Hello"})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment