Last active
December 13, 2015 22:19
-
-
Save syusui-s/4983466 to your computer and use it in GitHub Desktop.
Twitpic for mikutter
---> https://github.com/syusui-s/mikutter_twitpic_uploader
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 -*- | |
require 'twitpic-full' | |
Plugin.create(:mikutter_twitpic_uploader) do | |
UserConfig[:twitpic_upimg] = "" | |
UserConfig[:twitpic_message] = "" | |
twitpic = TwitPic::Client.new() | |
twitpic.configure do |conf| | |
# 気にしたらいけない。 | |
conf.api_key = "9b1d5ca2076eaa7029c83717dd641b47" | |
conf.consumer_key = CHIConfig::TWITTER_CONSUMER_KEY | |
conf.consumer_secret = CHIConfig::TWITTER_CONSUMER_SECRET | |
conf.oauth_token = UserConfig[:twitter_token] | |
conf.oauth_secret = UserConfig[:twitter_secret] | |
end | |
settings "Twitpicアップローダ" do | |
input "ツイート内容", :twitpic_message; | |
fileselect("アップロード画像", :twitpic_upimg, "~/") | |
closeup post = ::Gtk::Button.new('アップロード') | |
closeup attention = ::Gtk::Label.new("") | |
attention.wrap = true | |
post.signal_connect("clicked"){ | |
post.sensitive = false | |
upimg = UserConfig[:twitpic_upimg] | |
message = UserConfig[:twitpic_message] | |
if upimg != "" and FileTest.exist?(upimg) and (File.extname(upimg) =~ /^(\.jpg|\.jpeg|\.gif|\.png)$/i) == 0 then | |
Thread.new{ | |
attention.text = "アップロード中..." | |
twitpic.upload(upimg, message) # returns media? | |
}.next{ | |
user = twitpic.users(:show, {:username => Service.primary.idname}) | |
Service.primary.post :message => "#{message} http://twitpic.com/#{user['images'][0]['short_id']}" | |
attention.text = "完了しました! あなたのタイムラインをご確認ください." | |
UserConfig[:twitpic_message] = "" | |
UserConfig[:twitpic_upimg] = "" | |
}.terminate("Twitpicアップローダは、投稿に失敗しました.") | |
Reserver.new(7){ | |
attention.text = "" | |
post.sensitive = true } | |
else | |
attention.text = "指定されたファイルが見つからないか、アップロードできない拡張子です. 中止." | |
post.sensitive = true | |
end | |
} | |
end | |
end |
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
--- | |
slug: :twitpic_uploader | |
depends: | |
mikutter: 0.2 | |
plugin: | |
- settings | |
- twitpic-full | |
version: 1.0 | |
author: syusui_s | |
name: Twitpicアップローダ | |
description: Twitpic for mikutter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment