Skip to content

Instantly share code, notes, and snippets.

@siyo
Forked from DOGEME/teiji.rb
Last active December 15, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siyo/5290196 to your computer and use it in GitHub Desktop.
Save siyo/5290196 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# teiji tweet / earthquake plugin
#
# src: http://shindanmaker.com/311937
#
require 'httpclient'
require 'nokogiri'
Earthquake.init do
command %r|^:teiji\s*(.+)?|, :as => :teiji do |m|
url = "http://shindanmaker.com/311937"
res = HTTPClient.new.post(url, { :u => rand(Time.now.to_i), :from => ""} )
html = Nokogiri::HTML(res.body)
text = html.css("#forcopy").text.strip
input m[1] ? text.force_encoding('utf-8').gsub("出社",m[1]) : text
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment