Skip to content

Instantly share code, notes, and snippets.

@phelrine
Created January 22, 2012 15:15
Show Gist options
  • Save phelrine/1657341 to your computer and use it in GitHub Desktop.
Save phelrine/1657341 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'pit'
require 'twitter_oauth'
def convert_row(semivowel, roman, step)
head = semivowel.unpack("U*")[0]
(0..4).map{|i| [[head + step * i].pack("U*"), roman + %w(a i u e o)[i]]}
end
def find_kanakon_status_id(client, chr)
user = client.show("kanakon_" + chr)
return unless user["status"]
return user["status"]["id_str"]
end
raise if ARGV.length < 1
config = Pit.get("twitter-oauth")
client = TwitterOAuth::Client.new(
:consumer_key => config["consumer-key"],
:consumer_secret => config["consumer-secret"],
:token => config["access-token"],
:secret => config["access-secret"]
)
KANA_HASH = Hash[*[
["あ", "", 2],
["か", "k", 2],
["さ", "s", 2],
["な", "n", 1],
["は", "h", 3],
["ま", "m", 1],
["ら", "r", 1],
["が", "g", 2],
["ざ", "z", 2],
["だ", "d", 2],
["ば", "b", 3],
["ぱ", "p", 3],
["ぁ", "l", 2]
].reduce([]){|r, l| r + convert_row(*l)}.flatten +
%w(た ta ち ti つ tu て te と to や ya ゆ yu よ yo わ wa を wo ん n ー _)
]
ARGV[0].split("").map{|e|
find_kanakon_status_id(client, KANA_HASH[e])
}.reverse.each{|e|
next unless e
client.retweet(e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment