Skip to content

twitch irc implementation on scala using akka actors

Notifications You must be signed in to change notification settings

AmirMuratov/TwitchIRC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitch IRC

Twitch irc implementation on scala using akka actors. Twitch server API described here

Usage

Twitch bot is an actor which sends messages about all events to it's listeners.

Messages that can be sent to TwitchIRCActor

  • Join(channelName: String)
  • Part(channelName: String)
  • SendMessage(channelName: String, message: String)
  • SendWhisper(userName: String, message: String)
  • AddListener(listener: ActorRef)
  • DeleteListener(listener: ActorRef)

Events

if tags is disabled then tags are empty

success/fail log in events:

  • ConnectionFailed(err: String)
  • Connected

event after logging in(contains information about user in tags)

  • GlobalUserState(tags: Map[String, String])

message events:

  • IncomingMessage(tags: Map[String, String], user: String, channel: String, message: String)
  • IncomingWhisper(tags: Map[String, String], user: String, message: String)

sent only if membership is enabled:

  • UserJoinedChannel(user: String, channel: String)
  • UserLeftChannel(user: String, channel: String)
  • UserGainModeMessage(user: String, channel: String)
  • UserLostModeMessage(user: String, channel: String)
  • ChannelUserList(channel: String, users: Seq[String])

sent only if commands is enabled:

  • UserBan(tags: Map[String, String], channel: String, user: String)
  • HostStart(channel: String, hostChannel: String, viewers: Option[Int])
  • HostStop(channel: String, viewers: Option[Int])
  • Notice(tags: Map[String, String], channel: String, message: String)
  • RoomState(tags: Map[String, String], channel: String)
  • UserNotice(tags: Map[String, String], channel: String, message: String)
  • UserState(tags: Map[String, String], channel: String)

Usage example

Code inside actor:

import bot.twitchirc.TwitchIRCActor
import bot.twitchirc.TwitchIRCActor.{AddListener, TwitchIRCProps}

val twitchIRCActor = context.actorOf(TwitchIRCActor.props(nick, oauth,
    props = TwitchIRCProps(membership = true, tags = true, commands = true)), "TwitchIRCActor")
  twitchIRCActor ! AddListener(self)

nick - twitch login

oauth - can be obtained here

TwitchIRCProps - case class with properties:

  • membership - server send information about users join/left. Described here.
  • tags - additional information about users/events in messages. Described here.
  • commands - adds additional commands. Described here.

Add to sbt

resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.AmirMuratov" % "TwitchIRC" % "0.1"

About

twitch irc implementation on scala using akka actors

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages