From 03573a9abd0871ada1d1bdce6c4bce19a4a25cad Mon Sep 17 00:00:00 2001 From: AmirMuratov Date: Mon, 2 Apr 2018 16:07:33 +0300 Subject: [PATCH] ... --- README.md | 14 +++++++++++--- src/main/scala/bot/twitchirc/TCPClientActor.scala | 13 +++++-------- src/main/scala/bot/twitchirc/TwitchIRCActor.scala | 1 + .../bot/twitchirc/messages/MessageParser.scala | 1 - 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 16f1691..fceaf1a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Twitch IRC Twitch irc implementation on scala using akka actors. Twitch server API described [here](https://dev.twitch.tv/docs/irc) ### Usage -Twitch bot is an actor which sends messages about all events to its listeners. +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)``` @@ -39,7 +39,7 @@ sent only if ```commands``` is enabled: * ```UserNotice(tags: Map[String, String], channel: String, message: String)``` * ```UserState(tags: Map[String, String], channel: String)``` -### Creating example +### Usage example Code inside actor: ``` import bot.twitchirc.TwitchIRCActor @@ -49,9 +49,17 @@ 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](https://twitchapps.com/tmi/) ### TwitchIRCProps - case class with properties: * membership - server send information about users join/left. Described [here](https://dev.twitch.tv/docs/irc#twitch-irc-capability-membership). * tags - additional information about users/events in messages. Described [here](https://dev.twitch.tv/docs/irc#twitch-irc-capability-tags). -* commands - adds additional commands. Described [here](https://dev.twitch.tv/docs/irc#twitch-irc-capability-commands). \ No newline at end of file +* commands - adds additional commands. Described [here](https://dev.twitch.tv/docs/irc#twitch-irc-capability-commands). + +### Add to sbt +``` +resolvers += "jitpack" at "https://jitpack.io" +libraryDependencies += "com.github.AmirMuratov" % "TwitchIRC" % "0.1" +``` \ No newline at end of file diff --git a/src/main/scala/bot/twitchirc/TCPClientActor.scala b/src/main/scala/bot/twitchirc/TCPClientActor.scala index cc9eb8c..8b68a97 100644 --- a/src/main/scala/bot/twitchirc/TCPClientActor.scala +++ b/src/main/scala/bot/twitchirc/TCPClientActor.scala @@ -10,7 +10,7 @@ import bot.twitchirc.TCPClientActor.{CloseConnection, DataReceived, SendData, Wr /** * Created by amir. */ -class TCPClientActor(remote: InetSocketAddress) extends Actor with ActorLogging { +private[twitchirc] class TCPClientActor(remote: InetSocketAddress) extends Actor with ActorLogging { import Tcp._ import context.system @@ -61,19 +61,16 @@ object TCPClientActor { def props(remote: InetSocketAddress) = Props(classOf[TCPClientActor], remote) - //send result of connecting to parent case object Connected case class ConnectionFailed(message: String) - //messages sent to listener on events - case class DataReceived(data: String) + private[twitchirc] case class DataReceived(data: String) - case class WriteFailed(data: String) + private[twitchirc] case class WriteFailed(data: String) - //messages that can be sent - case class SendData(data: String) + private[twitchirc] case class SendData(data: String) - case object CloseConnection + private[twitchirc] case object CloseConnection } \ No newline at end of file diff --git a/src/main/scala/bot/twitchirc/TwitchIRCActor.scala b/src/main/scala/bot/twitchirc/TwitchIRCActor.scala index 55967b9..623c956 100644 --- a/src/main/scala/bot/twitchirc/TwitchIRCActor.scala +++ b/src/main/scala/bot/twitchirc/TwitchIRCActor.scala @@ -174,6 +174,7 @@ object TwitchIRCActor { sealed trait BotType case object KnownBot extends BotType + case object Verified extends BotType private val defaultAddress = new InetSocketAddress("irc.chat.twitch.tv", 6667) diff --git a/src/main/scala/bot/twitchirc/messages/MessageParser.scala b/src/main/scala/bot/twitchirc/messages/MessageParser.scala index ee79358..62c4f45 100644 --- a/src/main/scala/bot/twitchirc/messages/MessageParser.scala +++ b/src/main/scala/bot/twitchirc/messages/MessageParser.scala @@ -76,7 +76,6 @@ class MessageParser(nick: String) { users.split(" ") } - //@ban-duration=;ban-reason= private def parseTags(tags: String): Map[String, String] = { tags.tail split ";" map { tag => val parsedTag = tag.split("=", -1)