sugilite 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/discord.xml +3 -0
- data/.idea/sugilite.iml +0 -4
- data/Gemfile.lock +2 -11
- data/lib/sugilite.rb +30 -18
- data/lib/sugilite/version.rb +2 -2
- data/lib/sugiliteKraken.rb +22 -6
- data/sugilite.gemspec +0 -2
- metadata +1 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b309aea8e2896ebfd8c1a90852cfa753265c5302ebbd7b211a3264ddc035cb57
|
4
|
+
data.tar.gz: 2dc607114cbf68a6950e9fd6056500e1eebd8488785a8f9f2556ad4e6c989b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17b36a1c440ea60313ee14ca33996effc848dd3ee8a39f761a1ad551991008d2e683def9a359984f71fca4a5d2afd46c5577342d34f7f291fa6b19c9196954a9
|
7
|
+
data.tar.gz: a216c16ca6defaedb1c7af3d091c5b0a9c325190ef3db1e962a9248f104a800eb56c6c5c80029e0f67be3a6031dd9b19dd899adda25f87794ddbac706a4394c2
|
data/.idea/discord.xml
CHANGED
data/.idea/sugilite.iml
CHANGED
@@ -9,8 +9,6 @@
|
|
9
9
|
<orderEntry type="sourceFolder" forTests="false" />
|
10
10
|
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.0.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
11
11
|
<orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.20190701, RVM: ruby-2.6.3) [gem]" level="application" />
|
12
|
-
<orderEntry type="library" scope="PROVIDED" name="eventmachine (v1.2.7, RVM: ruby-2.6.3) [gem]" level="application" />
|
13
|
-
<orderEntry type="library" scope="PROVIDED" name="faye-websocket (v0.10.9, RVM: ruby-2.6.3) [gem]" level="application" />
|
14
12
|
<orderEntry type="library" scope="PROVIDED" name="http-accept (v1.7.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
15
13
|
<orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
16
14
|
<orderEntry type="library" scope="PROVIDED" name="mime-types (v3.2.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
@@ -23,7 +21,5 @@
|
|
23
21
|
<orderEntry type="library" scope="PROVIDED" name="rest-client (v2.1.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
24
22
|
<orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
25
23
|
<orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.7.6, RVM: ruby-2.6.3) [gem]" level="application" />
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.7.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
28
24
|
</component>
|
29
25
|
</module>
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sugilite (0.1.
|
4
|
+
sugilite (0.1.4)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
domain_name (0.5.20190701)
|
10
10
|
unf (>= 0.0.5, < 1.0.0)
|
11
|
-
eventmachine (1.2.7)
|
12
|
-
faye-websocket (0.10.9)
|
13
|
-
eventmachine (>= 0.12.0)
|
14
|
-
websocket-driver (>= 0.5.1)
|
15
11
|
http-accept (1.7.0)
|
16
12
|
http-cookie (1.0.3)
|
17
13
|
domain_name (~> 0.5)
|
@@ -20,7 +16,7 @@ GEM
|
|
20
16
|
mime-types-data (3.2019.0331)
|
21
17
|
minitest (5.11.3)
|
22
18
|
netrc (0.11.0)
|
23
|
-
oj (3.9.
|
19
|
+
oj (3.9.1)
|
24
20
|
rake (10.5.0)
|
25
21
|
rake-compiler (1.0.7)
|
26
22
|
rake
|
@@ -32,17 +28,12 @@ GEM
|
|
32
28
|
unf (0.1.4)
|
33
29
|
unf_ext
|
34
30
|
unf_ext (0.0.7.6)
|
35
|
-
websocket-driver (0.7.1)
|
36
|
-
websocket-extensions (>= 0.1.0)
|
37
|
-
websocket-extensions (0.1.4)
|
38
31
|
|
39
32
|
PLATFORMS
|
40
33
|
ruby
|
41
34
|
|
42
35
|
DEPENDENCIES
|
43
36
|
bundler (~> 2.0)
|
44
|
-
eventmachine (~> 1.2, >= 1.2.7)
|
45
|
-
faye-websocket (~> 0.10.9)
|
46
37
|
minitest (~> 5.0)
|
47
38
|
oj (~> 3.9.0)
|
48
39
|
rake (~> 10.0)
|
data/lib/sugilite.rb
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
#require 'Sugilite/version'
|
5
5
|
# require 'Sugilite/Sugilite'
|
6
6
|
require 'oj'
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
require '
|
7
|
+
require 'net/http'
|
8
|
+
require 'uri'
|
9
|
+
require 'pry'
|
10
10
|
local_dir = File.expand_path('../')
|
11
11
|
$LOAD_PATH.unshift(local_dir)
|
12
|
-
require 'sugiliteIRC
|
12
|
+
require 'sugiliteIRC'
|
13
|
+
require 'sugiliteKraken'
|
13
14
|
|
14
15
|
# Work with Twitch TMI to pull data
|
15
16
|
module Sugilite
|
@@ -23,68 +24,79 @@ module Sugilite
|
|
23
24
|
# New message
|
24
25
|
def initialize(channel)
|
25
26
|
# Users Channel
|
26
|
-
@
|
27
|
-
end
|
28
|
-
|
29
|
-
# url
|
30
|
-
def url
|
31
|
-
@url = "https://tmi.twitch.tv/group/user/#{@channel}/chatters"
|
27
|
+
@url = URI("https://tmi.twitch.tv/group/user/#{channel}/chatters")
|
32
28
|
end
|
33
29
|
|
34
30
|
# list all users on channel
|
35
31
|
def all
|
36
32
|
userlist = []
|
37
|
-
getchan =
|
33
|
+
getchan = Net::HTTP.get(@url)
|
38
34
|
userary = Oj.load(getchan).fetch('chatters')
|
39
35
|
userary.keys.each { |k| userary[k].each { |user| userlist.push(user) } }
|
40
36
|
userlist
|
41
37
|
end
|
38
|
+
|
39
|
+
# Pick a random viewer of your channel, with out any special ranks.
|
40
|
+
def randomviewer
|
41
|
+
getchan = Net::HTTP.get(@url)
|
42
|
+
userary = Oj.load(getchan).fetch('chatters').fetch('viewers')
|
43
|
+
userary.sample
|
44
|
+
end
|
45
|
+
|
46
|
+
# Pick a random viewer from all in channel.
|
47
|
+
def random
|
48
|
+
userlist = []
|
49
|
+
getchan = Net::HTTP.get(@url)
|
50
|
+
userary = Oj.load(getchan).fetch('chatters')
|
51
|
+
userary.keys.each { |k| userary[k].each { |user| userlist.push(user) } }
|
52
|
+
userlist.sample
|
53
|
+
end
|
42
54
|
|
43
55
|
# lists the broadcaster in channel
|
44
56
|
def broadcaster
|
45
|
-
getchan =
|
57
|
+
getchan = Net::HTTP.get(@url)
|
46
58
|
userary = Oj.load(getchan).fetch('chatters').fetch('broadcaster')
|
47
59
|
userary
|
48
60
|
end
|
49
61
|
|
50
62
|
# lists any vips in channel
|
51
63
|
def vip
|
52
|
-
getchan =
|
64
|
+
getchan = Net::HTTP.get(@url)
|
53
65
|
userary = Oj.load(getchan).fetch('chatters').fetch('vips')
|
54
66
|
userary
|
55
67
|
end
|
56
68
|
|
57
69
|
# lists any moderators in channel
|
58
70
|
def moderator
|
59
|
-
getchan =
|
71
|
+
getchan = Net::HTTP.get(@url)
|
60
72
|
userary = Oj.load(getchan).fetch('chatters').fetch('moderators')
|
61
73
|
userary
|
62
74
|
end
|
63
75
|
|
64
76
|
# lists any staff in channel
|
65
77
|
def staff
|
66
|
-
getchan =
|
78
|
+
getchan = Net::HTTP.get(@url)
|
67
79
|
userary = Oj.load(getchan).fetch('chatters').fetch('staff')
|
68
80
|
userary
|
69
81
|
end
|
70
82
|
|
71
83
|
# lists any admins in channel
|
72
84
|
def admin
|
73
|
-
getchan =
|
85
|
+
getchan = Net::HTTP.get(@url)
|
74
86
|
userary = Oj.load(getchan).fetch('chatters').fetch('admins')
|
75
87
|
userary
|
76
88
|
end
|
77
89
|
|
78
90
|
# lists any global moderators in channel (possibly depricated)
|
79
91
|
def global_mod
|
80
|
-
getchan =
|
92
|
+
getchan = Net::HTTP.get(@url)
|
81
93
|
userary = Oj.load(getchan).fetch('chatters').fetch('global_mods')
|
82
94
|
userary
|
83
95
|
end
|
84
96
|
|
85
97
|
# lists viewers
|
86
98
|
def viewer
|
87
|
-
getchan =
|
99
|
+
getchan = Net::HTTP.get(@url)
|
88
100
|
userary = Oj.load(getchan).fetch('chatters').fetch('viewers')
|
89
101
|
userary
|
90
102
|
end
|
data/lib/sugilite/version.rb
CHANGED
data/lib/sugiliteKraken.rb
CHANGED
@@ -6,26 +6,28 @@ require 'net/http'
|
|
6
6
|
require 'uri'
|
7
7
|
|
8
8
|
# Twitch Kraken API tools
|
9
|
-
module
|
9
|
+
module Sugilite
|
10
10
|
# retrieve channel chatrooms from Twitch Kraken
|
11
|
-
class
|
11
|
+
class Kraken
|
12
12
|
# direct access to the response from net::http
|
13
13
|
attr_accessor(:response)
|
14
14
|
|
15
15
|
# get things up and running
|
16
|
-
def initialize(channel_id, client_id, auth)
|
16
|
+
def initialize(*channel_id, client_id, auth)
|
17
17
|
# channel id of Twitch Channel
|
18
18
|
@channel_id = channel_id
|
19
19
|
# client id of user trying to access Twitch api
|
20
20
|
@client_id = client_id
|
21
21
|
# OAuth of person trying to access Twitch API
|
22
22
|
@auth = "OAuth #{auth}"
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
+
# Convert username to userid
|
26
|
+
def getuserid(username)
|
27
|
+
uri = URI.parse("https://api.twitch.tv/kraken/users?login=#{username}")
|
25
28
|
request = Net::HTTP::Get.new(uri)
|
26
29
|
request['Accept'] = 'application/vnd.twitchtv.v5+json'
|
27
30
|
request['Client-Id'] = @client_id
|
28
|
-
request['Authorization'] = @auth
|
29
31
|
|
30
32
|
req_options = {
|
31
33
|
use_ssl: uri.scheme == 'https'
|
@@ -33,10 +35,24 @@ module SugiliteKraken
|
|
33
35
|
@response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
34
36
|
http.request(request)
|
35
37
|
end
|
38
|
+
id = Oj.load(@response.body, mode: :object)
|
39
|
+
id.fetch('users')[0].fetch('_id')
|
36
40
|
end
|
37
41
|
|
38
|
-
#
|
42
|
+
# Get chat rooms for user id specified
|
39
43
|
def getrooms
|
44
|
+
uri = URI.parse("https://api.twitch.tv/kraken/chat/#{@channel_id[0]}/rooms")
|
45
|
+
request = Net::HTTP::Get.new(uri)
|
46
|
+
request['Accept'] = 'application/vnd.twitchtv.v5+json'
|
47
|
+
request['Client-Id'] = @client_id
|
48
|
+
request['Authorization'] = @auth
|
49
|
+
|
50
|
+
req_options = {
|
51
|
+
use_ssl: uri.scheme == 'https'
|
52
|
+
}
|
53
|
+
@response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
54
|
+
http.request(request)
|
55
|
+
end
|
40
56
|
Oj.load(@response.body, mode: :object)
|
41
57
|
end
|
42
58
|
end
|
data/sugilite.gemspec
CHANGED
@@ -30,8 +30,6 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.extensions = ["ext/sugilite/extconf.rb"]
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
33
|
-
spec.add_development_dependency 'eventmachine', '~> 1.2', '>= 1.2.7'
|
34
|
-
spec.add_development_dependency 'faye-websocket', '~> 0.10.9'
|
35
33
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
36
34
|
spec.add_development_dependency 'oj', '~> 3.9.0'
|
37
35
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugilite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MediaMagnet
|
@@ -24,40 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: eventmachine
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.2'
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 1.2.7
|
37
|
-
type: :development
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '1.2'
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 1.2.7
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: faye-websocket
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 0.10.9
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 0.10.9
|
61
27
|
- !ruby/object:Gem::Dependency
|
62
28
|
name: minitest
|
63
29
|
requirement: !ruby/object:Gem::Requirement
|