From 63985f0a7d687d891d2b9c700820df6b960e0edc Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 26 Aug 2024 23:41:32 -0400 Subject: [PATCH] fuck --- src/handling.cr | 90 ++++++++++++++++++++++++++++------- src/providers/bttv.cr | 2 +- src/providers/chatterino.cr | 6 +-- src/providers/chatty.cr | 4 +- src/providers/dankChat.cr | 4 +- src/providers/frankerFazeZ.cr | 2 +- src/vanity-tester-backend.cr | 2 +- 7 files changed, 83 insertions(+), 27 deletions(-) diff --git a/src/handling.cr b/src/handling.cr index 7a094d8..a6d6e5a 100644 --- a/src/handling.cr +++ b/src/handling.cr @@ -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 diff --git a/src/providers/bttv.cr b/src/providers/bttv.cr index ba8a0b9..08a27ee 100644 --- a/src/providers/bttv.cr +++ b/src/providers/bttv.cr @@ -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 diff --git a/src/providers/chatterino.cr b/src/providers/chatterino.cr index 08531ea..1bd56e1 100644 --- a/src/providers/chatterino.cr +++ b/src/providers/chatterino.cr @@ -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 \ No newline at end of file +end diff --git a/src/providers/chatty.cr b/src/providers/chatty.cr index b2014b1..8a69dad 100644 --- a/src/providers/chatty.cr +++ b/src/providers/chatty.cr @@ -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 \ No newline at end of file +end diff --git a/src/providers/dankChat.cr b/src/providers/dankChat.cr index 3e57227..757486a 100644 --- a/src/providers/dankChat.cr +++ b/src/providers/dankChat.cr @@ -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 \ No newline at end of file +end diff --git a/src/providers/frankerFazeZ.cr b/src/providers/frankerFazeZ.cr index ab74d15..7c0a96b 100644 --- a/src/providers/frankerFazeZ.cr +++ b/src/providers/frankerFazeZ.cr @@ -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) diff --git a/src/vanity-tester-backend.cr b/src/vanity-tester-backend.cr index 48c587d..f2bf2b7 100644 --- a/src/vanity-tester-backend.cr +++ b/src/vanity-tester-backend.cr @@ -21,4 +21,4 @@ get "/badges" do |env| Handlers.parse_badges(env) end -Kemal.run \ No newline at end of file +Kemal.run