Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
my_config.yml
config.yml
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GEM

PLATFORMS
ruby
x64-mingw32

DEPENDENCIES
cinch
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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?
-----------------
Expand Down
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
twitch_api:
username:
oauth_key:
oauth_key:
client_id:
mos_bot:
log_level: info
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/mos_bot_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ def play(chan)
logger.info "[#{chan}] PLAY REQUESTED! triggered on " \
"#{@channels[chan].play_requests} play requests"
end
end
end
16 changes: 8 additions & 8 deletions lib/stream_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
}
Expand All @@ -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
Expand All @@ -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