Created
September 22, 2014 07:53
-
-
Save ywindish/ac4929aa96125b88bfdf to your computer and use it in GitHub Desktop.
DajarebotのScala版
This file contains 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
/* | |
Scala勉強中 | |
同じディレクトリに以下を置きます | |
twitter4j-core-x.x.x.jar | |
twitter4j.properties | |
dajare.txt | |
以下で実行します | |
$ scala -cp .;twitter4j-core-x.x.x.jar dajarebot.scala | |
*/ | |
import scala.io.Source | |
import scala.util.Random | |
import twitter4j._ | |
import twitter4j.conf._ | |
object Main { | |
def main(args: Array[String]): Unit = { | |
run() | |
} | |
def run(): Unit = { | |
val f = Source.fromFile("dajare.txt", "utf-8") | |
val words = try f.getLines.toList finally f.close | |
val tweet = words(Random.nextInt(words.size)) + " #dajare" | |
val twitter = new TwitterFactory().getInstance() | |
twitter.updateStatus(tweet) | |
println(tweet) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment