GithubHelp home page GithubHelp logo

wooodenleg / tmik Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 1.0 157 KB

Twitch messaging in Kotlin - Simple DSL for interacting with Twitch chat

License: MIT License

Kotlin 100.00%
kotlin kotlin-dsl kotlin-js kotlin-jvm multiplatform twitch twitch-irc

tmik's People

Contributors

mkpazon avatar wooodenleg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mkpazon

tmik's Issues

[Intermittent] join(channel) sometimes does nothing

Several times when I call join(channel) to join a channel it doesn't do anything. This usually happens during development.

Does it ever happen that a bot stays in the channel even after your app has already closed? If it does, what happens if I try to join(channel) with a new session. Will the library allow it?

After waiting for a couple of minutes, joining becomes successful again.

Reconnect plugin in Kotlin/JS throws Exception

TmiK version:

0.0.5

Description:

Empty project with Reconnect plugin throws ReferenceError

Steps to reproduce:

  1. Create Kotlin/Js project with Node
  2. In main setup MainScope and add Reconnectplugin
tmi("oauth:token") {
  + Reconnect(10)
}

Stack trace:

ReferenceError: filterMessage$lambda is not defined
    at Coroutine$onTwitchMessage$lambda.doResume (C:\Users\Filip\Documents\wooodenbot-old\build\node_modules_imported\TmiK\TmiK.js:20405:29)
    at Coroutine$onTwitchMessage$lambda.CoroutineImpl.resumeWith_tl1gpc$ (C:\Users\Filip\Documents\wooodenbot-old\build\node_modules_imported\kotlin\kotlin.js:27964:35)
    at DispatchedContinuation.DispatchedTask.run (C:\Users\Filip\Documents\wooodenbot-old\build\node_modules_imported\kotlinx-coroutines-core\kotlinx-coroutines-core.js:2784:22)
    at NodeJsMessageQueue.MessageQueue.process (C:\Users\Filip\Documents\wooodenbot-old\build\node_modules_imported\kotlinx-coroutines-core\kotlinx-coroutines-core.js:30922:15)
    at C:\Users\Filip\Documents\wooodenbot-old\build\node_modules_imported\kotlinx-coroutines-core\kotlinx-coroutines-core.js:30873:27
    at process._tickCallback (internal/process/next_tick.js:61:11)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)

Sample on letting the bot join different channels

Does the library allow joining different channels?

Should I have a tmi(token = "...", context = this.coroutineContext) { ... } block for each channel I am joining or can I use the same tmi block?

NumberFormatException in rawmessages after Twitch "predictions" has been introduced

A couple of days ago Twitch introduced Predictions . I am not entirely sure how it works, but what is clear is that it crashes the app due to a NumberFormatException. Here is an example RawMessage :

RawMessage(raw=@badge-info=predictions/Yes\si\sthink\sso,subscriber/11;badges=predictions/blue-1 ...)

It crashes in the badges bit blue-1 with a NumberFormatException

Here is the stacktrace:

java.lang.NumberFormatException: For input string: "blue-1"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:652)
    at java.lang.Integer.parseInt(Integer.java:770)
    at com.ktmi.tmi.messages.UtilityKt.parseTwitchPairSet(Utility.kt:52)
    at com.ktmi.tmi.messages.TwitchMessagesKt.get_badges(TwitchMessages.kt:41)
    at com.ktmi.tmi.messages.TwitchMessagesKt.access$get_badges$p(TwitchMessages.kt:1)
    at com.ktmi.tmi.messages.TextMessage.getBadges(TwitchMessages.kt:150)
    at com.ktmi.tmi.messages.TwitchMessagesKt.isSubscriber(TwitchMessages.kt:32)

Does not run in browser

browser.js?b00d:4 Uncaught Error: ws does not work in the browser. Browser clients must use the native WebSocket object
    at new module.exports (webpack-internal:///../../node_modules/ws/browser.js:4)
    at IRC.connect (webpack-internal:///./kotlin-dce-dev/TmiK.js:95329)
    at TmiClient.connect (webpack-internal:///./kotlin-dce-dev/TmiK.js:698)
    at eval (webpack-internal:///./kotlin-dce-dev/overlay.js:804)
    at eval (webpack-internal:///./kotlin-dce-dev/kotlin-wrappers-kotlin-react-js-legacy.js:804)
    at commitHookEffectListMount (webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:19731)
    at commitPassiveHookEffects (webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:19769)
    at HTMLUnknownElement.callCallback (webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:237)
    at invokeGuardedCallback (webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:292)
    ```

What is the proper way of making the app join a channel later

First off, I think you've done a really good job in this library. I'd really like to see this to be somewhat of a standard for TMI on Kotlin.

My use case is that I start the server but do not join a channel in onConnected right away. Another event triggers the joining of the channel (eg. an API call). What I have been doing is to store a reference of the mainscope so that later on I can use it to join a channel.

What if tmi(token) { ... } returns an object which exposes an API to join a channel?

 var mainScope: MainScope? = null

.
.
.

tmi(token) {
     mainScope = this <--------------
    + Reconnect(5) // Tries to reconnect for five times if network fails (and re-joins all channels)

     onUserJoin {
         printlnWithThread("onUserJoin ${this.channel}: ${this.username}")
     }


   

    onMessage {
         println("Message from channel $channel received: $text")
    }

    onConnected {
          // Do no thing.    <------------------ notice that I don't join the channel yet                           
    }
}
.
.
.
  suspend fun joinChannel(channel: String) = coroutineScope {
        launch {
            mainScope?.join(channel)
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.