Skip to content

Instantly share code, notes, and snippets.

@kkosuge
Last active December 11, 2015 01:19
Show Gist options
  • Save kkosuge/4522764 to your computer and use it in GitHub Desktop.
Save kkosuge/4522764 to your computer and use it in GitHub Desktop.
# coding: utf-8
require "chatroid"
require "im-kayac"
def im_push(text)
ImKayac.post(ENV["IM_KAYAC_USERNAME"], text, { :password => ENV["IM_KAYAC_PASSWORD"] })
end
im_push("Start Chatroid")
Chatroid.new do
set :service, "Twitter"
set :consumer_key, ENV["CONSUMER_KEY"]
set :consumer_secret, ENV["CONSUMER_SECRET"]
set :access_key, ENV["ACCESS_KEY"]
set :access_secret, ENV["ACCESS_SECRET"]
on_tweet do |event|
if event["text"] =~ /98?m|kosuge|こすげ|コスゲ|コスゲ|小菅/i
sn = event["user"]["screen_name"]
via = event["source"].scan(/">(.+)</)[0][0]
im_push "#{sn}: #{event["text"]}(via #{via})"
end
end
end.run!
source 'https://rubygems.org'
gem 'chatroid'
gem 'im-kayac'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment