Skip to content

Instantly share code, notes, and snippets.

@yohfee
Created February 23, 2012 09:43
Show Gist options
  • Select an option

  • Save yohfee/1891970 to your computer and use it in GitHub Desktop.

Select an option

Save yohfee/1891970 to your computer and use it in GitHub Desktop.
コイツ誰?って思ったとき用のearthquake.gemプラグイン(要libnotify)
#coding: utf-8
begin
require 'libnotify'
require 'tempfile'
require 'open-uri'
Earthquake.init do
help :who, 'show user name and icon', <<-HELP
⚡ :who yohfee
HELP
command :who do |m|
user = twitter.show(m[1])
if user.key?("error")
puts user["error"]
else
Tempfile.open $$.to_s do |file|
begin
file.binmode
file.write open(user["profile_image_url"]).read
file.close
Libnotify.show summary: "#{user["screen_name"]} (#{user["name"]})",
body: ERB::Util.html_escape(user["description"]),
icon_path: file.path,
timeout: 1.0
ensure
file.unlink
end
end
end
end
end
rescue LoadError
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment