-
-
Save ryumu/2963973 to your computer and use it in GitHub Desktop.
gistでいじってからテストするのいくない。
This file contains 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 | |
# emoji plugin | |
# ==== | |
# | |
# You can post Emoji easily 😄 | |
# | |
# Usage | |
# ---- | |
# | |
# ⚡ heading to Shibuya :train: | |
# ⚡ :zzz: | |
# | |
# See also: | |
# ---- | |
# | |
# * https://github.com/jugyo/named_emoji | |
# * http://www.emoji-cheat-sheet.com/ | |
# | |
require 'named_emoji' | |
Earthquake.init do | |
input_filter do |text| | |
next text unless text =~ %r|^(:\w+)| | |
text.gsub(/:([^\s:]+):/) do |emoji_name| | |
NamedEmoji.emojis[$1.to_sym] || emoji_name | |
end | |
end | |
completion do |text| | |
next [] if Readline.line_buffer.strip == text | |
regexp = /^#{Regexp.quote(text)}/ | |
NamedEmoji::ALL.keys.map {|i| ":#{i}:"}.grep(regexp) | |
end | |
command :emojis do | |
puts NamedEmoji::ALL.map {|k, v| "#{v} #{k}"}.join(" ") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment