diff --git a/src/datahandlers/twitch.cr b/src/datahandlers/twitch.cr index 83b65b3..f18a992 100644 --- a/src/datahandlers/twitch.cr +++ b/src/datahandlers/twitch.cr @@ -27,6 +27,14 @@ module TwAPI::Datahandlers::Twitch end end + private macro isBanned2(gql, mode) + if {{gql}}["userResultBy#{{mode}}"]["reason"]? + true + else + false + end + end + def user(env) mode = env.params.query.has_key?("id") ? "ID" : "Login" @@ -391,7 +399,7 @@ module TwAPI::Datahandlers::Twitch json.field "daysRemaining", gql["info"]["relationship"]["streak"]["daysRemaining"]? json.field "months", gql["info"]["relationship"]["streak"]["months"]? json.field "end", gql["info"]["relationship"]["streak"]["end"]? - json.field "start", gql["info"]["relationship"]["streak"]["elapsedDays"]? + json.field "start", gql["info"]["relationship"]["streak"]["start"]? end end end @@ -404,7 +412,7 @@ module TwAPI::Datahandlers::Twitch json.field "daysRemaining", gql["info"]["relationship"]["cumulative"]["daysRemaining"]? json.field "months", gql["info"]["relationship"]["cumulative"]["months"]? json.field "end", gql["info"]["relationship"]["cumulative"]["end"]? - json.field "start", gql["info"]["relationship"]["cumulative"]["elapsedDays"]? + json.field "start", gql["info"]["relationship"]["cumulative"]["start"]? end end end @@ -413,8 +421,14 @@ module TwAPI::Datahandlers::Twitch else json.field "meta" do json.object do - json.field "type", nil # TODO: get the type of the sub, could be paid or something else gql["info"]["relationship"]["meta"][""] - json.field "tier", (gql["info"]["relationship"]["meta"]["tier"].to_s.to_i / 1000) + if json.field "type", gql["info"]["relationship"]["meta"]["giftMeta"]["isGift"] == false + json.field "type", "paid" + elsif gql["info"]["relationship"]["meta"]["purchasedWithPrime"] == true + json.field "type", "prime" + else + json.field "type", "gift" + end + json.field "tier", (gql["info"]["relationship"]["meta"]["tier"].to_s.to_i // 1000) json.field "endsAt", gql["info"]["relationship"]["meta"]["endsAt"] json.field "renewsAt", gql["info"]["relationship"]["meta"]["renewsAt"] json.field "giftMeta", nil # TODO: fill giftMeta is sub is gifted diff --git a/src/twitchapi/gqlapi.cr b/src/twitchapi/gqlapi.cr index 7f2b86b..6c3068f 100644 --- a/src/twitchapi/gqlapi.cr +++ b/src/twitchapi/gqlapi.cr @@ -30,33 +30,23 @@ module TwAPI::TwitchAPI::GQL emoticonPrefix { name } panels(hideExtensions: false) { id type } followers { totalCount } - roles { - isStaff - isAffiliate - isPartner - isExtensionsDeveloper - } - displayBadges { - setID - title - description - version - } + roles { isStaff isAffiliate isPartner isExtensionsDeveloper } + displayBadges { setID title description version } chatSettings { - autoModLevel - blockLinks - chatDelayMs - followersOnlyDurationMinutes - isBroadcasterLanguageModeEnabled - isEmoteOnlyModeEnabled - isFastSubsModeEnabled - isOptedOutOfGlobalBannedWordsList - isSubscribersOnlyModeEnabled - isUniqueChatModeEnabled - requireVerifiedAccount - rules - slowModeDurationSeconds - } + autoModLevel + blockLinks + chatDelayMs + followersOnlyDurationMinutes + isBroadcasterLanguageModeEnabled + isEmoteOnlyModeEnabled + isFastSubsModeEnabled + isOptedOutOfGlobalBannedWordsList + isSubscribersOnlyModeEnabled + isUniqueChatModeEnabled + requireVerifiedAccount + rules + slowModeDurationSeconds + } stream { averageFPS bitrate @@ -69,18 +59,9 @@ module TwAPI::TwitchAPI::GQL type game{displayName} } - lastBroadcast { - game{displayName} - id - startedAt - title - } + lastBroadcast { game{displayName} id startedAt title } channel { - chatters { - count - moderators { login } - vips { login } - } + chatters { count moderators {login} vips {login} } } } }