This commit is contained in:
Fijxu 2024-08-26 23:41:32 -04:00
parent b837512329
commit 63985f0a7d
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
7 changed files with 83 additions and 27 deletions

View file

@ -7,24 +7,80 @@ end
module Handlers
extend self
# @@erm = [] of JSON::Any | Nil
@@channel = Channel(JSON::Any).new
@@erm = [] of JSON::Any | Nil
@@buhh = ["bttv", "chatty"]
def buh
@@buhh.each do |iden|
spawn do
@@erm << Test.test(iden)
# chatterino_badges = Providers::Chatterino.get_badges
# chatty_badges = Providers::Chatty.get_badges
# ffz_badges = Providers::FFZ.get_badges
# dankchat_badges = Providers::DankChat.get_badges
end
end
pp @@erm
end
# @@buhh = ["bttv", "chatty"]
#
# def buh
# @@buhh.each do |iden|
# spawn do
# @@erm << Test.test(iden)
# # chatterino_badges = Providers::Chatterino.get_badges
# # chatty_badges = Providers::Chatty.get_badges
# # ffz_badges = Providers::FFZ.get_badges
# # dankchat_badges = Providers::DankChat.get_badges
# end
# end
# pp @@erm
# end
#
# def parse_badges(env)
# wg = WaitGroup.new
# spawn do
# puts "Chatterino"
# Providers::Chatterino.get_badges
# ensure
# wg.done
# end
# spawn do
# puts "Chatty"
# Providers::Chatty.get_badges
# ensure
# wg.done
# end
# wg.wait
# pp "buh"
# end
def parse_badges(env)
buh
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
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

View file

@ -3,6 +3,6 @@ module Providers::BTTV
def get_badges
res = HTTP::Client.get("https://api.betterttv.net/3/cached/badges/twitch", headers: HEADERS)
return JSON.parse(res.body)
JSON.parse(res.body)
end
end

View file

@ -2,7 +2,7 @@ module Providers::Chatterino
extend self
def get_badges
res = HTTP::Client.get("https://api.chatterino.com/badges", headers: HEADERS)
return JSON.parse(res.body)
res = HTTP::Client.get("https://api.chatterino.com/badges", headers: HEADERS)
JSON.parse(res.body)
end
end
end

View file

@ -3,6 +3,6 @@ module Providers::Chatty
def get_badges
res = HTTP::Client.get("https://tduva.com/res/badges", headers: HEADERS)
return JSON.parse(res.body)
JSON.parse(res.body)
end
end
end

View file

@ -4,6 +4,6 @@ module Providers::DankChat
def get_badges
res = HTTP::Client.get("https://flxrs.com/api/badges", headers: HEADERS)
return JSON.parse(res.body)
JSON.parse(res.body)
end
end
end

View file

@ -42,7 +42,7 @@ module Providers::FFZ
def get_badges
res = HTTP::Client.get("https://api.frankerfacez.com/v1/badges/ids", headers: HEADERS)
return JSON.parse(res.body)
JSON.parse(res.body)
end
# def get_channel(channel_id : String)

View file

@ -21,4 +21,4 @@ get "/badges" do |env|
Handlers.parse_badges(env)
end
Kemal.run
Kemal.run