適当に喋るtwitter botを作る
これをcronに登録して喋らせてみている
http://d.hatena.ne.jp/shokai/20080320/1205987790
でSQLiteに保存しておいた名詞と動詞を組み合わせて、間に適当な接続詞をランダムに入れてみながら喋る
#!/usr/bin/ruby require 'rubygems' require 'active_record' require 'models.rb' gem 'twitter' require 'twitter' ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :dbfile => '/var/sqlite3/oktwitter-friends' ) words = Array.new cons = ['が','で','に','を','は','も','へ','だ','さ','と','な','の','や'] #verbs = Verb.find(:all) #verbs.each{ |v| # if rand(verbs.length) > verbs.length-8 && v.text.length > 6 # words << v.text # end #} nouns = Noun.find(:all) nouns.each{ |n| if rand(nouns.length) > nouns.length-5 && n.text.length > 3 words << n.text end } exit(true) if words.length < 3 twit = Twitter::Base.new("username","password") words.sort_by{rand} message = '' words.each{ |w| message << w message << cons[rand(cons.length)] if rand > 0.6 } twit.update(Kconv.kconv(message, Kconv::UTF8)) puts message