lib/legion/legion.rb in legion_mastodon_client-0.1.1 vs lib/legion/legion.rb in legion_mastodon_client-0.1.2

- old
+ new

@@ -3,25 +3,50 @@ require 'dotenv' require 'tk' require_relative 'mastodon' require_relative 'ui' +def ClientInit + Dotenv.load + + client = Array.new + + url = ENV["MASTODON_URL"].split(",") + token = ENV["MASTODON_TOKEN"].split(",") + + for i in 0...url.count do + client[i] = Mastodon::REST::Client.new(base_url: url[i], bearer_token: token[i]) + end + + mastodon = MastodonAPI.new(client) +end + +def StreamInit + Dotenv.load + + stream = Array.new + + url = ENV["MASTODON_URL"].split(",") + token = ENV["MASTODON_TOKEN"].split(",") + + for i in 0...url.count do + stream[i] = Mastodon::Streaming::Client.new(base_url: url[i], bearer_token: token[i]) + end + + streaming = MastodonStreaming.new(stream, url) +end + def LegionLoop window = TkRoot.new do #タイトルバーの表示 title( "Legion" ) end -Dotenv.load +mastodon = ClientInit() +streaming = StreamInit() -client = Mastodon::REST::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"]) -mastodon = MastodonAPI.new(client) - -stream = Mastodon::Streaming::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"]) -streaming = MastodonStreaming.new(stream) - tootFrame = TootFrame.new(window, mastodon) -tootFrame.set +tootFrame.set(window, streaming) home_timeline = Timeline.new(window, "ホームタイムライン") home_timeline.set home_timeline_yscrollbar = TkScrollbar.new(home_timeline.list) {orient "vertical"; command proc{|*args| home_timeline.list.yview(*args);} } \ No newline at end of file