Last active
August 29, 2015 13:56
-
-
Save penguin2716/8931669 to your computer and use it in GitHub Desktop.
投稿文字列の3文字以上のアルファベット文字列(internationalizationとか)を縮めて(i18nとか)ツイートするmikutterプラグイン
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 -*- | |
Plugin.create :shrink_words do | |
def shrink_words(src) | |
str = src | |
src.scan(/[a-zA-Z_]+/).map{ |s| | |
if s.size > 3 | |
[s, s[0] + (s.size - 2).to_s + s[-1]] | |
else | |
[s, s] | |
end | |
}.each{ |pair| | |
str.sub!(pair[0], pair[1]) | |
} | |
str | |
end | |
filter_gui_postbox_post do |gui_postbox| | |
src = Plugin.create(:gtk).widgetof(gui_postbox).widget_post.buffer.text | |
text = shrink_words(src) | |
Service.primary.post :message => text | |
Plugin.call(:before_postbox_post, text) | |
Plugin.create(:gtk).widgetof(gui_postbox).widget_post.buffer.text = '' | |
Plugin.filter_cancel! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment