Skip to content

Instantly share code, notes, and snippets.

@penguin2716
Last active December 14, 2015 23:19
Show Gist options
  • Save penguin2716/5164913 to your computer and use it in GitHub Desktop.
Save penguin2716/5164913 to your computer and use it in GitHub Desktop.
Postboxに入力した内容をmikutterコマンドとして実行するmikutterプラグイン
# -*- coding: utf-8 -*-
Plugin.create :post_as_mikutter_command do
command(:post_as_mikutter_command,
name: 'mikutterコマンドとして実行',
condition: lambda{ |opt| Plugin.create(:gtk).widgetof(opt.widget).widget_post.buffer.text.size > 0 },
visible: true,
role: :postbox) do |opt|
begin
command = Plugin.create(:gtk).widgetof(opt.widget).widget_post.buffer.text
Plugin.call(:before_postbox_post, command)
result = Kernel.instance_eval(command)
Plugin.create(:gtk).widgetof(opt.widget).widget_post.buffer.text = ""
rescue Exception => e
Plugin.call(:update, nil, [Message.new(:message => e.to_s, :system => true)])
e.backtrace
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment