Created
May 15, 2012 03:03
-
-
Save pedrofurla/2698782 to your computer and use it in GitHub Desktop.
Multibot scala part. Possibly missing imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/lopex/multibot/blob/master/src/main/scala/org/multibot/Multibot.scala | |
// line 87 | |
val scalaInt = scala.collection.mutable.Map[String, IMain]() | |
def scalaInterpreter(channel: String)(f: (IMain, ByteArrayOutputStream) => Unit) = this.synchronized { | |
val si = scalaInt.getOrElseUpdate(channel, { | |
val settings = new scala.tools.nsc.Settings(null) | |
settings.usejavacp.value = true | |
settings.deprecation.value = true | |
val si = new IMain(settings) { override def parentClassLoader = Thread.currentThread.getContextClassLoader } | |
si.quietImport("scalaz._") | |
si.quietImport("Scalaz._") | |
si.quietImport("org.scalacheck.Prop._") | |
si | |
}) | |
captureOutput{f(si, conOut)} | |
} | |
// one invokation of the interpreter | |
scalaInterpreter(msg.channel){(si, cout) => | |
import scala.tools.nsc.interpreter.Results._ | |
sendLines(msg.channel, (si interpret m match { | |
case Success => cout.toString.replaceAll("(?m:^res[0-9]+: )", "") // + "\n" + iout.toString.replaceAll("(?m:^res[0-9]+: )", "") | |
case Error => cout.toString.replaceAll("^<console>:[0-9]+: ", "") | |
case Incomplete => "error: unexpected EOF found, incomplete expression" | |
})) | |
//.split("\n") take NUMLINES foreach (m => sendMessage(msg.channel, " " + (if (m.charAt(0) == 13) m.substring(1) else m))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment