Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: colder/scalaircbot
base: 896aa800af
...
head fork: colder/scalaircbot
compare: c3314d3519
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
6 src/main/scala/Config.scala
@@ -5,18 +5,18 @@ import scala.xml._
class Config(path: String) {
private val data = XML.loadFile(path)
- private val db = data \ "db" head
+ private val db = (data \ "db").head
val dbUser = (db \ "@user").text
val dbPass = (db \ "@pass").text
val dbDatabase = (db \ "@database").text
val dbHost = (db \ "@host").text
val dbPort = (db \ "@port").text.toInt
- private val host = data \ "host" head
+ private val host = (data \ "host").head
val hostHost = (host \ "@host").text
val hostPort = Integer.parseInt((host \ "@port").text)
- private val auth = data \ "auth" head
+ private val auth = (data \ "auth").head
val authNick = Nick((auth \ "@nick").text)
val authIdent = Ident((auth \ "@ident").text)
val authPass = (auth \ "@pass").text
View
18 src/main/scala/Control.scala
@@ -69,11 +69,11 @@ class Control(val cfg: Config) extends Actor {
l.info("Loading Ident Module...")
/* Freenode Idents attached to Nicks */
- idents = new modules.Idents(this)
+ idents = new modules.Idents(this)
trackers.registerNickTracker(idents)
l.info("Loading BanLog Module...")
- banlog = new modules.BanLog(this)
+ banlog = new modules.BanLog(this)
l.info("Loading Factoid Module...")
factoids = new modules.Factoids(this)
@@ -96,7 +96,7 @@ class Control(val cfg: Config) extends Actor {
/* Register a specific module */
def registerModule(module: Module) {
modulesList = modulesList ::: module :: Nil
- module init
+ module.init
}
/* Register all default modules */
@@ -180,7 +180,7 @@ class Control(val cfg: Config) extends Actor {
def shutdown() {
l.info("Shutting down...");
- shutdownModules
+ modulesList.foreach(_.shutdown)
if (db != null) {
db.close
@@ -208,14 +208,4 @@ class Control(val cfg: Config) extends Actor {
def writeLine(line: String) {
c ! InnerProtocol.WriteLine(line)
}
-
- /* call shutdown on all modules */
- def shutdownModules = {
- modulesList foreach { _ shutdown }
- }
-
- /* Inform modules that we got reconnected */
- def reconnectModules = {
- modulesList foreach { _ reconnect }
- }
}
View
2  src/main/scala/Module.scala
@@ -5,6 +5,4 @@ abstract class Module(ctl: Control) {
def handleMessage(message: Message): Boolean;
def shutdown = {};
def reconnect = {};
-
- implicit var onReplies = collection.mutable.Map[Long, PartialFunction[Message, Unit]]()
}
View
2  src/main/scala/modules/Yahoo.scala
@@ -39,7 +39,7 @@ class Yahoo(val ctl: Control) extends Module(ctl) with Commands with Http {
val res = httpRequest("http://boss.yahooapis.com/ysearch/web/v1/"+pattern_enc+"?appid=WD0C1ofIkY21IlNLjmFl6lC.l7cdajU-&format=xml&filter=-porn-hate&count=5&style=raw")
val xml = scala.xml.XML.load(res)
- val results = (xml \\ "result") map { r => SearchResult((r \ "abstract").text, (r \ "url").text) } toList
+ val results = (xml \\ "result").map { r => SearchResult((r \ "abstract").text, (r \ "url").text) }.toList
SearchResults(results, Integer.parseInt((xml \ "resultset_web" \ "@totalhits").text))
View
12 src/main/scala/utils/Commands.scala
@@ -81,7 +81,9 @@ trait Commands {
def onReply[T : ClassTag](pf: PartialFunction[Message, Option[T]]): Future[T] = {
val la = ctl.getContext.actorOf(Props(new ListeningActor(pf)), name = "la")
- ask(la, Start)(Timeout(timeout)).mapTo[T]
+ val f = ask(la, Start)(Timeout(timeout)).mapTo[T]
+ body
+ f
}
def waitUntilReply[T : ClassTag](pf: PartialFunction[Message, Option[T]]): Option[T] = {
@@ -98,7 +100,13 @@ trait Commands {
None
}
- Await.result(f, timeout)
+ try {
+ Await.result(f, timeout)
+ } catch {
+ case e: Throwable =>
+ ctl.l.err("execute { .. } onReply { .. } timeout!")
+ None
+ }
}
}
View
2  src/main/scala/utils/HelpInfo.scala
@@ -16,7 +16,7 @@ trait SimpleHelp extends HelpInfo {
val commandsHelp: Map[String, (Set[UserLevel], String, String)]
override def generalHelpInfo(access: UserLevel) = {
- commandsHelp collect { case (cmd, (accesses, proto, desc)) if accesses contains access => (proto, desc) } toSeq
+ commandsHelp.collect{ case (cmd, (accesses, proto, desc)) if accesses contains access => (proto, desc) }.toSeq
}
override def specificHelp = {

No commit comments for this range

Something went wrong with that request. Please try again.