This repository was archived by the owner on Oct 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstream.rb
More file actions
56 lines (44 loc) · 1.51 KB
/
stream.rb
File metadata and controls
56 lines (44 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#-- vim:sw=2:et
#++
#
# :title: eric quote
#
# Author:: xx
#
#
# License:: GPL v2
require 'nokogiri'
require 'json'
class StreamPlugin < Plugin
API_URL = "http://api.justin.tv/api/stream/list.json"
CHANNELS = {}#{"#capcom" => ["iplaywinner","madcatz","nycfurby","topangatv","freida0914","teamsp00ky","gostunv","leveluplive","armshouse","ogamingtv"],"##x" => ["draskyll","blitzdota","nycfurby","topangatv","freida0914","teamsp00ky","gostunv","leveluplive","massivelytv"]}
def initialize
super
@data = @registry['0']
@registry.set_default({})
@apiPingLoop = @bot.timer.add(100) do
chans = CHANNELS.select{|q| @bot.channels.map(&:name).include?(q[0])}
debug chans
return if chans.empty?
chans.each do |chan,s|
debug s.inspect
s.each do |channel|
debug "KEY "+channel.inspect+" / VAL "+@data[channel].inspect
streams = JSON(@bot.httputil.get(API_URL+"?channel="+channel))
unless streams.first.nil?
@bot.say chan,channel+" live - "+streams.first["title"]+" http://twitch.tv/"+channel if Time.parse(streams.first["up_time"]).to_i > @data[channel].to_i+10800
debug "pushing "+Time.parse(streams.first["up_time"]).to_i.to_s+"to db"
@data[channel] = Time.parse(streams.first["up_time"]).to_i
end
end
end
end
def cleanup
@bot.timer.remove(@apiPingLoop)
#@registry['0'] = @data
@registry.vanish
super
end
end
end
#plugin = StreamPlugin.new