Skip to content

Instantly share code, notes, and snippets.

@nna774
Last active August 29, 2015 14:01
Show Gist options
  • Save nna774/f7982a6c4b82c69f1b20 to your computer and use it in GitHub Desktop.
Save nna774/f7982a6c4b82c69f1b20 to your computer and use it in GitHub Desktop.
@miku md5sum <text>
#-*- coding: utf-8 -*-
# https://github.com/penguin2716/mikutter_shell_post を参考に書いた
Plugin.create :md5sum_post do
UserConfig[:md5sum_post_with_post] ||= false
# postboxの中身をクリアしてイベントをキャンセル
def self.clear_post(gui_postbox)
Plugin.call(:before_postbox_post,
Plugin.create(:gtk).widgetof(gui_postbox).widget_post.buffer.text)
Plugin.create(:gtk).widgetof(gui_postbox).widget_post.buffer.text = ''
Plugin.filter_cancel!
end
filter_gui_postbox_post do |gui_postbox|
text = Plugin.create(:gtk).widgetof(gui_postbox).widget_post.buffer.text
# if UserConfig[:shell_exec_with_post]
# Service.primary.post :message => (text[0] == '@') ? text.sub('@','') : text
# end
if text =~ /^@miku\s+(md5sum)\s+(.+)/
Thread.new {
result = ""
if UserConfig[:md5sum_post_with_post]
result += (text[0] == '@') ? text.sub('@','〄') : text
result += "\n"
end
str = $2
result += "md5sum: "
result += `echo #{str} | md5sum`
Service.primary.post :message => result
#Plugin.call(:update, nil, [Message.new(:message => "#{result}", :system => true)])
}
clear_post(gui_postbox)
end
[gui_postbox]
end
settings "original_post" do
boolean "元のコマンドをポストする", :md5sum_post_with_post
end
# command(:raw_post,
# name: '入力内容をそのまま投稿する',
# condition: lambda{ |opt| true },
# visible: true,
# role: :postbox) do |opt|
# Plugin.create(:gtk).widgetof(opt.widget).post_it
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment