0.2.0 • Published 2 years ago

tmi.res v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

tmi.res

ReScript bindings for the tmi.js library. For more info and documentation, checkout the original project here.

⚠️ DISCLAIMER: This library is not complete yet. But it has the basic bindings to get a chatbot up and running.

Install

yarn add tmi.js tmi.res

Add tmi.res to bs-dependencies in your bsconfig.json file:

"bs-dependencies": [
  "tmi.res"
]
open Tmi

let client = createClient(
  makeOptions(
    ~options=Options.make(~debug=true, ~messagesLogLevel=#info, ()),
    ~connection=Connection.make(~reconnect=true, ~secure=true, ()),
    ~identity=Identity.make(~username="bot-name", ~password="oath:my-bot-token"),
    ~channels=["my-channel"],
    (),
  ),
)

client->connect

let onMessageHandler = (channel, tags, message, self) => {
  if !self && message->Js.String2.toLocaleLowerCase == "!hello" {
    client->say(channel, `@${tags["username"]}, heya!`)
  }
}

client->on(#message(onMessageHandler))