Created
February 23, 2012 09:43
-
-
Save yohfee/1891970 to your computer and use it in GitHub Desktop.
コイツ誰?って思ったとき用のearthquake.gemプラグイン(要libnotify)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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