ivr-api-crystal/src/routes/twitch.cr

60 lines
1 KiB
Crystal

module TwAPI::Routes::Twitch
extend self
private macro handleData(func)
begin
TwAPI::Datahandlers::Twitch.{{func}}(env)
rescue ex
env.response.status_code = 404
err = {"error" => "#{ex.message}"}
err.to_json
end
end
def user(env)
if env.params.query.has_key?("login")
begin
handleData(userLogin)
rescue ex
puts ex.message
end
else
begin
handleData(userId)
rescue ex
puts ex.message
end
end
end
def modvip(env)
handleData(modvip)
end
def founders(env)
handleData(founders)
end
def clip(env)
handleData(clip)
end
def subage(env)
handleData(subage)
end
def emotes(env)
handleData(emotes)
end
end
# I'll do this later fuck this shit
# def globalEmotes(env)
# if !env.params.query.has_key?("id") || !env.params.query.has_key?("login")
# err = "[]"
# return err.to_json
# else
# gql = GqlAPI.getChannelEmotes(env.params.query)
# json_data = JSON.build do |json|
# end