cinch-twitch 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: b6634bff39fdfd6bd1e7852bc621bd7af376902a
4
+ data.tar.gz: 598b4dff44f3330e54a4aa053a19be94ddeeb6da
5
+ SHA512:
6
+ metadata.gz: e7b4f9fe650ec9cefcdbeb7eacb6baac2d03360938a5c836f0616ce70351391ac97e33029afbd5ff4957140cf09ca72b146907e97a46b778576c9357543a7ab3
7
+ data.tar.gz: 1995485fe283dc24bc25ae45d18e323cff13efa4db5816b6428fdee5d1581498ea58298092175936edb979912691eac68b879dfce5cf5d4e43b896ba9edd9159
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,44 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - 1.9.2
8
+ - 1.8.7
9
+ - jruby-18mode
10
+ - jruby-19mode
11
+ - ruby-head
12
+ - jruby-head
13
+ - ree
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: 1.8.7
17
+ - rvm: ree
18
+ - rvm: jruby-18mode
19
+ - rvm: jruby-19mode
20
+ - rvm: jruby-head
21
+ fast_finish: true
22
+ env:
23
+ global:
24
+ - JRUBY_OPTS=-Xcext.enabled=true
25
+ - secure: ! 'Yz/VAtfbXwk6JD/2/z6c2SGygNGELrF0dlZ/M5nOrDiKNm8lxpC6w19esGbB
26
+
27
+ CYt8UtqylceJ2UxYngHLVH48oPb+A5fv21/jDJMqHeO/N4WjwQUOzBZXfZG6
28
+
29
+ lpugXIsT9Q10q0AsXry65YuzZtpY7VkVQUNSBYte7jTcWbLmIWQ='
30
+ - secure: ! 'CbdMyExVnyHfPQ+scSky8JIlqK0dU7idBrtvipQIA2dGfIIj0lzuUDEqvtAv
31
+
32
+ +9A7Mw01ddxQ/tXdixHDBNOhp9Ddz+4/0OSMyIb/5uFy+l7b2B2K4A4R5crI
33
+
34
+ RBc5W5rgzRLnDD7HL4BZMRDpx3sJRLcIH9S4bclXyjkzQ7yzVDc='
35
+ - secure: ! 'Pl14JkhwMe+HHi1Ht0znd0+TnSzdSGvtG4pX8+oSWuIyfTd3xfoj7Pf1S4P/
36
+
37
+ 7SVnixq2gQh13OaL4Tj2sR6+AHz6n+onareFoKkZPSJuDRh6yXFfvKIdx4MV
38
+
39
+ l5lIJbSI4icPWOMk6ObMCzIb/m3m4Z/BG3O5E/6AcJDQa7rspL0='
40
+ - secure: ! 'Xrh52mNuRCf1kJHpZctrz3gfBZQ/rlC+qz/MlvZ9L7sm1CFSIoJdizrOYawt
41
+
42
+ cKOyLfsLrcnJqGbq0s++cSQ2QDggEGxtVkMXxIw7dBFn2icZsKsTN5rh28UR
43
+
44
+ W2TakLhFB8f+LQ+/P9PvV1wlSOJQRFItLjjOtcEoQVLi51Pwuzw='
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cinch-twitch.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Brian Haberer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Cinch::Twitch
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cinch-twitch'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cinch-twitch
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/cinch-twitch/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cinch/plugins/twitch/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cinch-twitch'
8
+ spec.version = Cinch::Plugins::TwitchTV::VERSION
9
+ spec.authors = ['Brian Haberer']
10
+ spec.email = ['bhaberer@gmail.com']
11
+ spec.description = %q(Cinch Plugin for monitoring TwitchTV streams)
12
+ spec.summary = %q(Cinch TwitchTV Plugin)
13
+ spec.homepage = 'https://github.com/bhaberer/cinch-twitch'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'rake', '~> 10'
22
+ spec.add_development_dependency 'rspec', '~> 3'
23
+ spec.add_development_dependency 'coveralls', '~> 0.7'
24
+ spec.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.0'
25
+ spec.add_dependency 'cinch', '~> 2'
26
+ spec.add_dependency 'twitch', '~> 0.0', '>= 0.0.2'
27
+ spec.add_dependency 'time-lord', '~> 1.0', '>= 1.0.1'
28
+ end
@@ -0,0 +1,2 @@
1
+ require 'cinch/plugins/twitch/version'
2
+ require 'cinch/plugins/twitch'
@@ -0,0 +1,69 @@
1
+ require 'cinch'
2
+ require 'twitch'
3
+ require 'time-lord'
4
+
5
+ module Cinch
6
+ module Plugins
7
+ # Cinch Plugin to monitor twitch streams and announce when they are live.
8
+ class TwitchTV
9
+ include Cinch::Plugin
10
+
11
+ match(/stream/)
12
+ timer 30, method: :live_check
13
+
14
+ def initialize(*args)
15
+ super
16
+ @streamid = config[:streamid]
17
+ @currently_live = live?
18
+ end
19
+
20
+ def execute(m)
21
+ m.reply stream_message, true
22
+ end
23
+
24
+ def live_check
25
+ if @currently_live == live?
26
+ debug "Stream is currently [#{live? ? 'Online' : 'Offline'}]"
27
+ return
28
+ end
29
+ debug "Stream status changed to [#{live? ? 'Online' : 'Offline'}]"
30
+ @bot.channels.first.msg(online_message) if live?
31
+ @currently_live = live?
32
+ end
33
+
34
+ private
35
+
36
+ def live?
37
+ !offline?
38
+ end
39
+
40
+ def offline?
41
+ acquire_stream_info.nil?
42
+ end
43
+
44
+ def stream_message
45
+ return 'Stream is offline' if offline?
46
+
47
+ info = acquire_stream_info
48
+ "#{info[:channel_name]} started broadcasting " \
49
+ "#{info[:started_at].ago.to_words}; listen along at #{info[:url]}"
50
+ end
51
+
52
+ def online_message
53
+ info = acquire_stream_info
54
+ "#{info[:channel_name]} is now Online at #{info[:url]}" unless info.nil?
55
+ end
56
+
57
+ def acquire_stream_info
58
+ stream = Twitch.new.getStream(@streamid)[:body]['stream']
59
+ return nil if stream.nil? || !stream.key?('channel')
60
+ channel = stream['channel']
61
+
62
+ { viewers: stream['viewers'],
63
+ channel_name: channel['display_name'],
64
+ started_at: Time.parse(channel['updated_at']),
65
+ url: channel['url'] }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,8 @@
1
+ module Cinch
2
+ module Plugins
3
+ # Versioning info
4
+ class TwitchTV
5
+ VERSION = '0.0.3'
6
+ end
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-twitch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Brian Haberer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cinch-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: 0.1.0
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '0.1'
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: 0.1.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: cinch
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: '2'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: '2'
89
+ - !ruby/object:Gem::Dependency
90
+ name: twitch
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '0.0'
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 0.0.2
99
+ type: :runtime
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: '0.0'
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: 0.0.2
109
+ - !ruby/object:Gem::Dependency
110
+ name: time-lord
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ~>
114
+ - !ruby/object:Gem::Version
115
+ version: '1.0'
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: 1.0.1
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.0'
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: 1.0.1
129
+ description: Cinch Plugin for monitoring TwitchTV streams
130
+ email:
131
+ - bhaberer@gmail.com
132
+ executables: []
133
+ extensions: []
134
+ extra_rdoc_files: []
135
+ files:
136
+ - .gitignore
137
+ - .travis.yml
138
+ - Gemfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - cinch-twitch.gemspec
143
+ - lib/cinch-twitch.rb
144
+ - lib/cinch/plugins/twitch.rb
145
+ - lib/cinch/plugins/twitch/version.rb
146
+ homepage: https://github.com/bhaberer/cinch-twitch
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.2.2
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Cinch TwitchTV Plugin
170
+ test_files: []