Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mikutterで通信を最適化してツイートするプラグイン
# -*- coding: utf-8 -*-
Plugin.create(:mikutter_optimized_tweet) do
command(:optimized_tweet,
name: '通信を最適化してツイートする',
condition: lambda{ |opt| true },
visible: true,
role: :postbox) do |opt|
begin
random = Random.new
message = Plugin.create(:gtk).widgetof(opt.widget).widget_post.buffer.text
nowlen = message.length
count = nowlen / 3 * 2 # 2/3くらい最適化する
count.times {|i|
pos = random.rand(0..nowlen)
message.slice!(pos, 1)
nowlen = message.length
}
Service.primary.update(:message => message)
defactivity "optimized_tweet", "optimized_tweet"
activity :optimized_tweet, "通信が最適化されました"
Plugin.create(:gtk).widgetof(opt.widget).widget_post.buffer.text = ''
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.