diff --git a/.gitignore b/.gitignore index e0a01f7..1d3ed4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -my_config.yml +config.yml diff --git a/Gemfile.lock b/Gemfile.lock index 5f31b8d..ef90a85 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,6 +8,7 @@ GEM PLATFORMS ruby + x64-mingw32 DEPENDENCIES cinch diff --git a/README.md b/README.md index 6a83145..74ceae3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ MOSBot    [![alt text](https://api.codeclimate.com/v1/badges/6ddeda072827f6726041/maintainability)](https://codeclimate.com/github/anderlechtt/mos_bot/maintainability) ====== -A bot playing [Marbles On Stream](http://pixelbypixelcanada.com/mos.html) with Twitch streamers. Written in Ruby. +A bot playing [Marbles On Stream](http://pixelbypixelcanada.com/mos.html) with Twitch streamers. Written in Ruby, migrated to Helix. How does it work? ----------------- diff --git a/config.yml b/config.yml index 40d8cd0..91e5ce1 100644 --- a/config.yml +++ b/config.yml @@ -1,6 +1,6 @@ twitch_api: username: - oauth_key: + oauth_key: client_id: mos_bot: log_level: info diff --git a/lib/plugins/mos_bot_plugin.rb b/lib/plugins/mos_bot_plugin.rb index ba6a936..7e168c6 100644 --- a/lib/plugins/mos_bot_plugin.rb +++ b/lib/plugins/mos_bot_plugin.rb @@ -108,4 +108,4 @@ def play(chan) logger.info "[#{chan}] PLAY REQUESTED! triggered on " \ "#{@channels[chan].play_requests} play requests" end -end +end \ No newline at end of file diff --git a/lib/stream_finder.rb b/lib/stream_finder.rb index e756667..c8b4ae8 100644 --- a/lib/stream_finder.rb +++ b/lib/stream_finder.rb @@ -3,13 +3,13 @@ # uses twich api to get mos live streams class StreamFinder def self.fetch_streams - url = 'https://api.twitch.tv/kraken/streams/' + url = 'https://api.twitch.tv/helix/streams/' options = { headers: { 'Client-ID' => Settings.twitch_api['client_id'] }, format: :plain, - query: { game: 'Marbles On Stream' } + query: { game_id: '509511' } } data = HTTParty.get(url, options) @@ -18,8 +18,8 @@ def self.fetch_streams def self.parse_stream(stream) { - stream[:channel][:name] => { - viewers: stream[:viewers], + stream[:user_name] => { + viewers: stream[:viewer_count], updated_at: Time.now } } @@ -28,10 +28,10 @@ def self.parse_stream(stream) def self.parse_streams(streams, min_viewers, max_channels) channels = {} - if streams[:_total] > 0 - streams[:streams].each do |stream| + if Array(streams[:data]).count > 0 + streams[:data].each do |stream| break if channels.size >= max_channels - next if stream[:viewers] < min_viewers + next if stream[:viewer_count] < min_viewers channels.merge! parse_stream(stream) end @@ -44,4 +44,4 @@ def self.find(min_viewers = 40, max_channels = 20) streams = fetch_streams parse_streams(streams, min_viewers, max_channels) end -end +end \ No newline at end of file