Last active
August 29, 2015 14:01
-
-
Save nna774/f7982a6c4b82c69f1b20 to your computer and use it in GitHub Desktop.
@miku md5sum <text>
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 -*- | |
# 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