wooodenleg / tmik Goto Github PK
View Code? Open in Web Editor NEWTwitch messaging in Kotlin - Simple DSL for interacting with Twitch chat
License: MIT License
Twitch messaging in Kotlin - Simple DSL for interacting with Twitch chat
License: MIT License
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.
0.0.5
Empty project with Reconnect plugin throws ReferenceError
tmi("oauth:token") {
+ Reconnect(10)
}
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)
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?
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)
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)
```
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)
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.