import info.mukel.telegrambot4s.api.{Commands, Polling, TelegramBot}
import org.json4s.native.JsonMethods._
import org.json4s._
import scala.io.Source
object BotImpl extends TelegramBot with Polling with Commands {
lazy val token:String = Source.fromFile("token.txt").getLines().mkString
on("/b", "oboobs") { implicit msg => _ =>
lazy val b = Source.fromURL("http://api.oboobs.ru/boobs/0/1/random/").getLines().mkString
lazy val j = parse(b)
lazy val previews = for {
JObject(model) <- j.children
JField("preview", JString(preview)) <- model
} yield s"http://media.oboobs.ru/boobs/${preview.stripPrefix("boobs_preview/")}"
reply(previews.mkString("\n"))
}
}
object Bot extends App {
BotImpl.run()
}