From 4732407d48834294d469826a91b2ba7666b2dc23 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Tue, 27 Aug 2024 14:23:31 -0400 Subject: [PATCH] 0.0.0.0.9 --- src/handling.cr | 60 +++++++++++++------------------------------ src/providers/main.cr | 14 +++++----- 2 files changed, 26 insertions(+), 48 deletions(-) diff --git a/src/handling.cr b/src/handling.cr index fc3688c..d0e5c06 100644 --- a/src/handling.cr +++ b/src/handling.cr @@ -1,48 +1,24 @@ -require "wait_group" - -macro xd(ident) -Providers::{{ident}}.get_badges -end - module Handlers extend self - # @@erm = [] of JSON::Any | Nil - @@channel = Channel(JSON::Any).new - - # @@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) - badges_tuple = Providers.get_all_badges + badges_tuple = Providers.get_all_badges + JSON.build do |j| + j.object do + j.field "chatterino" do + j.object do + j.field "badges" do + j.object do + j.field "name", badges_tuple[:chatterino]["badges"][0]["tooltip"] + # j.field "url1x", badges_tuple[:chatterino]. + # j.field "url2x", badges_tuple[:chatterino]. + # j.field "url3x", badges_tuple[:chatterino]. + # j.field "users", badges_tuple[:chatterino]. + end + end + end + end + end + end end end diff --git a/src/providers/main.cr b/src/providers/main.cr index 75e4d52..7fb8aa9 100644 --- a/src/providers/main.cr +++ b/src/providers/main.cr @@ -10,13 +10,15 @@ module Providers # bttv = Channel(JSON::Any).new # dankchat = Channel(JSON::Any).new # ffz = Channel(JSON::Any).new - info = Array(Channel(JSON::Any)).new(5) + info = [Channel(JSON::Any).new,Channel(JSON::Any).new,Channel(JSON::Any).new,Channel(JSON::Any).new,Channel(JSON::Any).new] # 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} + # 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: info.receive, ffz: ffz.receive, dankchat: dankchat.receive, chatty: chatty.receive} + items = {chatterino: info[0].receive} + return items end end