Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.
/ James Public archive

Micro chat framework for Kotlin (currently Rocket.Chat, Slack and Telegram)

License

Notifications You must be signed in to change notification settings

Ingwersaft/James

Repository files navigation

Release Download CircleCI

James

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)

Features

  • 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

Usage

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:

example

Take a look at the wiki or the Mapping.kt source for all possibilities

Target chat specifics

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())

Rocket.Chat

Change avatar (default :tophat:):

options.put("avatar",":alien:")

Telegram

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.

How to get James

James is published at jcenter and JitPack.

Gradle

allprojects {
    repositories {
        jcenter()
        ...or...
        maven { url 'https://jitpack.io' }
    }
}
...
dependencies {
    compile 'com.github.Ingwersaft:James:<Tag>'
}

Maven

<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>

Javadoc

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.

Build

$ git clone https://github.com/Ingwersaft/James.git && cd James
$ ./gradlew build

Release

// bintrayRelease & bintrayUpload are done using the circleci build
$ ./gradlew release

Known caveats

  • James doesn't execute retries in case of backend connection problems

About

Micro chat framework for Kotlin (currently Rocket.Chat, Slack and Telegram)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages