fuck
This commit is contained in:
parent
63985f0a7d
commit
e44630c3c3
10 changed files with 43 additions and 60 deletions
|
@ -12,6 +12,6 @@ class Config
|
||||||
config_file = "./config.yml"
|
config_file = "./config.yml"
|
||||||
config_yaml = File.read(config_file)
|
config_yaml = File.read(config_file)
|
||||||
config = Config.from_yaml(config_yaml)
|
config = Config.from_yaml(config_yaml)
|
||||||
config
|
config
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,14 +9,15 @@ module Handlers
|
||||||
|
|
||||||
# @@erm = [] of JSON::Any | Nil
|
# @@erm = [] of JSON::Any | Nil
|
||||||
@@channel = Channel(JSON::Any).new
|
@@channel = Channel(JSON::Any).new
|
||||||
|
|
||||||
# @@buhh = ["bttv", "chatty"]
|
# @@buhh = ["bttv", "chatty"]
|
||||||
#
|
#
|
||||||
# def buh
|
# def buh
|
||||||
# @@buhh.each do |iden|
|
# @@buhh.each do |iden|
|
||||||
# spawn do
|
# spawn do
|
||||||
# @@erm << Test.test(iden)
|
# @@erm << Test.test(iden)
|
||||||
# # chatterino_badges = Providers::Chatterino.get_badges
|
# # chatterino_badges = Providers::Chatterino.get_badges
|
||||||
# # chatty_badges = Providers::Chatty.get_badges
|
# # chatty_badges = Providers::Chatty.get_badges
|
||||||
# # ffz_badges = Providers::FFZ.get_badges
|
# # ffz_badges = Providers::FFZ.get_badges
|
||||||
# # dankchat_badges = Providers::DankChat.get_badges
|
# # dankchat_badges = Providers::DankChat.get_badges
|
||||||
# end
|
# end
|
||||||
|
@ -42,45 +43,6 @@ module Handlers
|
||||||
# pp "buh"
|
# pp "buh"
|
||||||
# end
|
# end
|
||||||
def parse_badges(env)
|
def parse_badges(env)
|
||||||
wg = WaitGroup.new(5)
|
badges_tuple = Providers.get_all_badges
|
||||||
arrr = [] of JSON::Any
|
|
||||||
# items = NamedTuple(chatterino: JSON::Any, chatty: JSON::Any, bttv: JSON::Any, dankchat: JSON::Any, ffz: JSON::Any)
|
|
||||||
chatterino = Channel(JSON::Any).new
|
|
||||||
chatty = Channel(JSON::Any).new
|
|
||||||
bttv = Channel(JSON::Any).new
|
|
||||||
dankchat = Channel(JSON::Any).new
|
|
||||||
ffz = Channel(JSON::Any).new
|
|
||||||
spawn do
|
|
||||||
chatterino.send(Providers::Chatterino.get_badges)
|
|
||||||
ensure
|
|
||||||
wg.done
|
|
||||||
end
|
|
||||||
spawn do
|
|
||||||
chatty.send(Providers::Chatty.get_badges)
|
|
||||||
ensure
|
|
||||||
wg.done
|
|
||||||
end
|
|
||||||
spawn do
|
|
||||||
bttv.send(Providers::BTTV.get_badges)
|
|
||||||
ensure
|
|
||||||
wg.done
|
|
||||||
end
|
|
||||||
spawn do
|
|
||||||
dankchat.send(Providers::DankChat.get_badges)
|
|
||||||
ensure
|
|
||||||
wg.done
|
|
||||||
end
|
|
||||||
spawn do
|
|
||||||
ffz.send(Providers::FFZ.get_badges)
|
|
||||||
ensure
|
|
||||||
wg.done
|
|
||||||
end
|
|
||||||
# wg.wait
|
|
||||||
items = {chatterino: chatterino.receive, bttv: bttv.receive, ffz: ffz.receive, dankchat: dankchat.receive, chatty: chatty.receive}
|
|
||||||
# arrr << channel.receive
|
|
||||||
# arrr << channel.receive
|
|
||||||
# arrr << channel.receive
|
|
||||||
# arrr << channel.receive
|
|
||||||
pp items[:chatterino]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
module Providers::SevenTV
|
module Providers::SevenTV
|
||||||
|
|
||||||
end
|
end
|
|
@ -3,6 +3,6 @@ module Providers::BTTV
|
||||||
|
|
||||||
def get_badges
|
def get_badges
|
||||||
res = HTTP::Client.get("https://api.betterttv.net/3/cached/badges/twitch", headers: HEADERS)
|
res = HTTP::Client.get("https://api.betterttv.net/3/cached/badges/twitch", headers: HEADERS)
|
||||||
JSON.parse(res.body)
|
JSON.parse(res.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Providers::Chatterino
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
def get_badges
|
def get_badges
|
||||||
res = HTTP::Client.get("https://api.chatterino.com/badges", headers: HEADERS)
|
res = HTTP::Client.get("https://api.chatterino.com/badges", headers: HEADERS)
|
||||||
JSON.parse(res.body)
|
JSON.parse(res.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,6 @@ module Providers::Chatty
|
||||||
|
|
||||||
def get_badges
|
def get_badges
|
||||||
res = HTTP::Client.get("https://tduva.com/res/badges", headers: HEADERS)
|
res = HTTP::Client.get("https://tduva.com/res/badges", headers: HEADERS)
|
||||||
JSON.parse(res.body)
|
JSON.parse(res.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,6 @@ module Providers::DankChat
|
||||||
|
|
||||||
def get_badges
|
def get_badges
|
||||||
res = HTTP::Client.get("https://flxrs.com/api/badges", headers: HEADERS)
|
res = HTTP::Client.get("https://flxrs.com/api/badges", headers: HEADERS)
|
||||||
JSON.parse(res.body)
|
JSON.parse(res.body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,8 +45,8 @@ module Providers::FFZ
|
||||||
JSON.parse(res.body)
|
JSON.parse(res.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# def get_channel(channel_id : String)
|
# def get_channel(channel_id : String)
|
||||||
# res = HTTP::Client.get("https://api.frankerfacez.com/v1/room/id/#{channel_id}", headers: HEADERS)
|
# res = HTTP::Client.get("https://api.frankerfacez.com/v1/room/id/#{channel_id}", headers: HEADERS)
|
||||||
# channel_data = JSON.parse(res.body)
|
# channel_data = JSON.parse(res.body)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
22
src/providers/main.cr
Normal file
22
src/providers/main.cr
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
module Providers
|
||||||
|
extend self
|
||||||
|
|
||||||
|
def get_all_badges : NamedTuple
|
||||||
|
# wg = WaitGroup.new(5)
|
||||||
|
# arrr = [] of JSON::Any
|
||||||
|
# items = NamedTuple(chatterino: JSON::Any, chatty: JSON::Any, bttv: JSON::Any, dankchat: JSON::Any, ffz: JSON::Any)
|
||||||
|
# chatterino = Channel(JSON::Any).new
|
||||||
|
# chatty = Channel(JSON::Any).new
|
||||||
|
# bttv = Channel(JSON::Any).new
|
||||||
|
# dankchat = Channel(JSON::Any).new
|
||||||
|
# ffz = Channel(JSON::Any).new
|
||||||
|
info = Array(Channel(JSON::Any)).new(5)
|
||||||
|
# Compile with -Dpreview_mt
|
||||||
|
spawn { info[0].send(Providers::Chatterino.get_badges) }
|
||||||
|
spawn { info[1].send(Providers::Chatty.get_badges) }
|
||||||
|
spawn { info[2].send(Providers::BTTV.get_badges) }
|
||||||
|
spawn { info[3].send(Providers::DankChat.get_badges) }
|
||||||
|
spawn { info[4].send(Providers::FFZ.get_badges) }
|
||||||
|
items = {chatterino: info[0].receive, bttv: bttv.receive, ffz: ffz.receive, dankchat: dankchat.receive, chatty: chatty.receive}
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,7 +8,7 @@ require "./config"
|
||||||
require "./handling"
|
require "./handling"
|
||||||
require "./providers/**"
|
require "./providers/**"
|
||||||
|
|
||||||
CONFIG = Config.load
|
CONFIG = Config.load
|
||||||
Kemal.config.port = CONFIG.port
|
Kemal.config.port = CONFIG.port
|
||||||
Kemal.config.shutdown_message = false
|
Kemal.config.shutdown_message = false
|
||||||
Kemal.config.app_name = "vanity-tester-backend"
|
Kemal.config.app_name = "vanity-tester-backend"
|
||||||
|
@ -18,7 +18,7 @@ REDIS_DB = Redis::Client.new(CONFIG.redisUrl)
|
||||||
HEADERS = HTTP::Headers{"User-Agent" => "Vanity-Tester-Backend/0.1.0"}
|
HEADERS = HTTP::Headers{"User-Agent" => "Vanity-Tester-Backend/0.1.0"}
|
||||||
|
|
||||||
get "/badges" do |env|
|
get "/badges" do |env|
|
||||||
Handlers.parse_badges(env)
|
Handlers.parse_badges(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
Kemal.run
|
Kemal.run
|
||||||
|
|
Loading…
Add table
Reference in a new issue