Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove some simple common bot stuff

  • Loading branch information...
commit 1861b2e6100b52835ce26f654ed9c69cb33ac089 1 parent 4e98702
Anders Conbere authored
View
3  src/main/scala/Bot.scala
@@ -4,8 +4,9 @@ import Messages._
import Tokens._
trait Bot {
- val rooms:List[Room] = List()
+ val rooms:List[Room]
val respondTo:PartialFunction[Message,Option[Response]]
+
val onConnect:Option[Response] = None
val defaultResponse:PartialFunction[Message,Option[Response]] = {
View
19 src/main/scala/ClassicBot.scala
@@ -0,0 +1,19 @@
+package org.conbere.irc
+
+import Messages._
+
+trait ClassicBot extends Bot {
+ val serverName:String
+ val nickName:String
+ val userName:String
+ val password:String
+ val realName:String
+
+ val hostName = java.net.InetAddress.getLocalHost.getHostName
+
+ override val onConnect =
+ Some(Pass(password) ++=
+ Nick(nickName) ++=
+ User(userName, hostName, serverName, realName))
+}
+
View
13 src/main/scala/ExampleBot.scala
@@ -1,6 +1,6 @@
package org.conbere.irc
-import Tokens._
+import Tokens.{ Message, Response }
import Messages._
import akka.actor._
import com.typesafe.scalalogging.log4j.Logging
@@ -10,15 +10,8 @@ class ExampleBot( val serverName:String
, val userName:String
, val password:String
, val realName:String
- , override val rooms:List[Room])
-extends Bot with Logging {
- val hostName = java.net.InetAddress.getLocalHost.getHostName
-
- override val onConnect =
- Some(Pass(password) ++=
- Nick(nickName) ++=
- User(userName, hostName, serverName, realName))
-
+ , val rooms:List[Room])
+extends ClassicBot with Logging {
val respondTo = defaultResponse.orElse[Message,Option[Response]] {
case PrivMsg(from, `nickName`, text) =>
Some(PrivMsg(from, text))
Please sign in to comment.
Something went wrong with that request. Please try again.