update
This commit is contained in:
parent
9e3e7b5397
commit
1c507cf7d6
2 changed files with 29 additions and 81 deletions
|
@ -6,17 +6,12 @@ module Users
|
|||
helixUsers = JSON.parse(HelixAPI.users(params))
|
||||
login = helixUsers["data"][0]["login"]
|
||||
id = helixUsers["data"][0]["id"]
|
||||
# gqlUser = JSON.parse(GqlAPI.user(idto))
|
||||
|
||||
gqlUser = GqlAPI.user(id.to_s)
|
||||
gqlChannel = GqlAPI.channel(id.to_s)
|
||||
# helixChatColor = JSON.parse(HelixAPI.chatColor(id))
|
||||
|
||||
helixChatColor = JSON.parse(HelixAPI.chatColor(id))
|
||||
# gqlCA = JSON.parse(GqlAPI.gqlReq("ChannelAvatar", "#{login}"))
|
||||
# gqlCS = JSON.parse(GqlAPI.gqlReq("ChannelShell", "#{login}"))
|
||||
|
||||
# gqlUser["chatSettings"]["rules"].to_json.each do |rule|
|
||||
# puts rule
|
||||
# end
|
||||
panels = gqlUser["panels"]
|
||||
|
||||
json_data = [
|
||||
{
|
||||
|
@ -25,34 +20,29 @@ module Users
|
|||
"login" => helixUsers["data"][0]["login"],
|
||||
"id" => helixUsers["data"][0]["id"],
|
||||
"bio" => helixUsers["data"][0]["description"],
|
||||
# "followers" => gqlUser[0]["data"]["user"]["followers"]["totalCount"],
|
||||
"follows" => nil,
|
||||
"followers" => gqlUser["followers"]["totalCount"],
|
||||
"profileViewCount" => nil, # Always null
|
||||
"panelCount" => "",
|
||||
"chatColor" => helixChatColor["data"][0]["color"],
|
||||
"panelCount" => panels.size,
|
||||
# "chatColor" => helixChatColor["data"][0]["color"],
|
||||
"logo" => gqlUser["profileImageURL"],
|
||||
"banner" => gqlUser["bannerImageURL"],
|
||||
"verifiedBot" => nil, # Deprecated by twitch
|
||||
"createdAt" => helixUsers["data"][0]["created_at"],
|
||||
"updatedAt" => nil,
|
||||
"createdAt" => gqlUser["createdAt"],
|
||||
"updatedAt" => gqlUser["updatedAt"],
|
||||
"deletedAt" => gqlUser["deletedAt"],
|
||||
"emotePrefix" => "lol",
|
||||
"chatterCount" => gqlChannel["chatters"]["count"],
|
||||
"roles" => {
|
||||
"isAffiliate" => gqlUser["roles"]["isAffiliate"],
|
||||
"isPartner" => gqlUser["roles"]["isPartner"],
|
||||
"isStaff" => gqlUser["roles"]["isStaff"],
|
||||
},
|
||||
"badges" => [
|
||||
{
|
||||
"setID" => "game-developer",
|
||||
"title" => "Game Developer",
|
||||
"description" => "Game Developer for:",
|
||||
"version" => "1",
|
||||
},
|
||||
],
|
||||
|
||||
"chatSettings" => { gqlUser["chatSettings"] },
|
||||
"badges" => gqlUser["displayBadges"],
|
||||
"chatterCount" => gqlChannel["chatters"]["count"],
|
||||
"chatSettings" => gqlUser["chatSettings"],
|
||||
"stream" => gqlUser["stream"],
|
||||
"lastBroadcast" => gqlUser["lastBroadcast"]
|
||||
"lastBroadcast" => gqlUser["lastBroadcast"],
|
||||
"panels" => panels,
|
||||
},
|
||||
]
|
||||
|
||||
|
|
|
@ -9,52 +9,18 @@ module GqlAPI
|
|||
"Client-Id" => "ue6666qo983tsx6so1t0vnawi233wa",
|
||||
}
|
||||
|
||||
def self.gqlOperation(operation : String, login : String)
|
||||
case operation
|
||||
when "ChannelShell"
|
||||
data = [
|
||||
{
|
||||
"operationName" => "#{operation}",
|
||||
"variables" => {
|
||||
"login" => "#{login}",
|
||||
},
|
||||
"extensions" => {
|
||||
"persistedQuery" => {
|
||||
"version" => 1,
|
||||
"sha256Hash" => "580ab410bcd0c1ad194224957ae2241e5d252b2c5173d8e0cce9d32d5bb14efe",
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
when "ChannelAvatar"
|
||||
data = [
|
||||
{
|
||||
"operationName" => "#{operation}",
|
||||
"variables" => {
|
||||
"channelLogin" => "#{login}",
|
||||
},
|
||||
"extensions" => {
|
||||
"persistedQuery" => {
|
||||
"version" => 1,
|
||||
"sha256Hash" => "84ed918aaa9aaf930e58ac81733f552abeef8ac26c0117746865428a7e5c8ab0",
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
end
|
||||
return data.to_json
|
||||
end
|
||||
|
||||
def self.gqlOperation2()
|
||||
data = { "query" => "{}" }
|
||||
return data.to_json
|
||||
end
|
||||
|
||||
def self.user(id : String)
|
||||
data = { "query" => "{user(id:#{id}){
|
||||
bannerImageURL,
|
||||
profileImageURL(width: 600),
|
||||
createdAt,
|
||||
updatedAt,
|
||||
deletedAt,
|
||||
panels(hideExtensions: false){id,type},
|
||||
follows(first: 1, after: buh, filter: ALL order: ASC){totalCount},
|
||||
followers(first: 1, after: buh, order: ASC){totalCount},
|
||||
roles{isStaff,isAffiliate,isPartner,isExtensionsDeveloper},
|
||||
displayBadges(){setID, title, description,version},
|
||||
chatSettings{blockLinks,chatDelayMs,slowModeDurationSeconds,followersOnlyDurationMinutes,isBroadcasterLanguageModeEnabled,isEmoteOnlyModeEnabled,isFastSubsModeEnabled,isSubscribersOnlyModeEnabled,isUniqueChatModeEnabled,requireVerifiedAccount,rules},
|
||||
stream{averageFPS,bitrate,codec,createdAt,width,height,id,viewersCount,type,game{displayName}},
|
||||
lastBroadcast{game{displayName},id,startedAt,title}
|
||||
|
@ -69,6 +35,13 @@ module GqlAPI
|
|||
return JSON.parse(gqlReq(id, data.to_json))["data"]["channel"]
|
||||
end
|
||||
|
||||
def self.query(id : String)
|
||||
data = { "query" => "{query(id:#{id}){
|
||||
chatters{count,moderators{login},vips{login}}
|
||||
}}" }
|
||||
return JSON.parse(gqlReq(id, data.to_json))["data"]["channel"]
|
||||
end
|
||||
|
||||
def self.gqlReq(id : String, data : String)
|
||||
response = HTTP::Client.post(CONFIG.gqlEndpoint.to_s, headers: @@headers, body: data)
|
||||
|
||||
|
@ -93,18 +66,3 @@ module GqlAPI
|
|||
# end
|
||||
end
|
||||
|
||||
{
|
||||
"4": {
|
||||
"extensions": {
|
||||
"persistedQuery": {
|
||||
"sha256Hash": "84ed918aaa9aaf930e58ac81733f552abeef8ac26c0117746865428a7e5c8ab0",
|
||||
"version": 1
|
||||
}
|
||||
},
|
||||
"operationName": "ChannelAvatar",
|
||||
"variables": {
|
||||
"channelLogin": "fijxu"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue