Micro chat framework for Kotlin.
Currently supports Rocket.Chat, Telegram and Slack as targets.
Regarding compatibility:
before 1.0.5: kotlin 1.2 with old experimental coroutines since 1.0.5: kotlin 1.3 with new coroutines (structured concurrency)
- Rocket.Chat via Websocket api
- Telegram
- Slack using Ullink/simple-slack-api
- minimal DSL
- conversation support
- automatic mapping overview aka
help
- Name your bot
- conversation support with retries
With...
fun main(args: Array<String>) {
james {
abortKeywords += "cancel"
abortKeywords += "abort"
rocketchat {
websocketTarget = "wss://example.org/websocket"
username = "example_bot"
password = "secret_password"
sslVerifyHostname = false
ignoreInvalidCa = true
}
name = "felix"
map("question", "i'll ask you for some text") {
val answer = ask("please provide some text:")
send("received: $answer")
}
map("dadjoke", "i'll send you a dadjoke") {
send("Someone broke into my house last night and stole my limbo trophy. How low can you go?")
}
}
}
... you get:
Take a look at the wiki or the Mapping.kt source for all possibilities
the send
and ask
methods support optional options:
// Mapping:
fun send(text: String, options: Map<String, String> = emptyMap())
fun ask(text: String, options: Map<String, String> = emptyMap())
Change avatar (default :tophat:
):
options.put("avatar",":alien:")
Parsemode (HTML
or Markdown
supported)
options["parse_mode"] == "Markdown"
Commands:
Every String with a leading /
is clickable inside telegram. This can be used in your mapping string, but also if you ask
a user some question, you can provide possible, clickable, values.
James is published at jcenter and JitPack.
allprojects {
repositories {
jcenter()
...or...
maven { url 'https://jitpack.io' }
}
}
...
dependencies {
compile 'com.github.Ingwersaft:James:<Tag>'
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
...or...
<repository>
<id>central</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
...
<dependency>
<groupId>com.github.Ingwersaft</groupId>
<artifactId>James</artifactId>
<version>#VERSION#</version>
</dependency>
Jitpack also provides javadoc web publishing. Use the URL
https://jitpack.io/com/github/Ingwersaft/James/<VERSION>/javadoc/
(e.g.: master-SNAPSHOT
or 1.0.5)
to access the javadoc for the given version.
$ git clone https://github.com/Ingwersaft/James.git && cd James
$ ./gradlew build
// bintrayRelease & bintrayUpload are done using the circleci build
$ ./gradlew release
- James doesn't execute retries in case of backend connection problems