0Seren / Scala.TwitchIRC

An IRC for twitch.tv
1 stars 1 forks source link

Scala.TwitchIRC

This project is centered around providing an easy to use and flexible Scala library that interacts with and adheres to Twitch Chat and their rules/rate limits. It does so in such a way that the user of the library shouldn't have to fear about breaking any rate limits or rules.

Pros:

Cons (TODO's):

Example Use:

val username = /*username*/
val oauth = /*"oauth:"rest of oauth token*/
val channels_to_join = List(/*...*/)
val irc = new TwitchIRC(username, oauth)

irc.joinChannel(username)
irc.joinChannels(channels_to_join)

for(i <- 1 to 9001){
  irc.sendMessage(i.toString, channel)
}

while(/*!done*/){
  irc.getMessage match {
    case None => /*no message has been recieved*/
    case Some(cm : ChannelMessage) => /*message sent to a channel's chat*/
    case Some(sm: StatusMessage) => /*message sent pertaining to something like "sub mode on"*/
    case Some(tm : TwitchMessage) => /*misc messages sent from twitch.tv*/
    case Some(pem: ParseErrorMessage) => /*messages unable to be parsed (should be logged and reported here)*/
    case Some(m : Message) => /*this should never occur, and if it does, it should be logged and reported here*/
    case _ => /*this should never occur, and if it does, it should be logged and reported here*/
  }
}

irc.close()

Output:

Output

As you can see, if messages are sent too quickly they may arrive in a different order than sent.