fixup! Chatty: Replace usernames by Twitch IDs
This commit is contained in:
parent
4aa51045eb
commit
b7b596618a
3 changed files with 14 additions and 5 deletions
|
@ -72,6 +72,7 @@ module Handlers
|
|||
j.field "name", name
|
||||
j.field "id", id
|
||||
j.field "url", url
|
||||
# TODO: En BTTV faltan los users xDD
|
||||
j.field "users", "xd"
|
||||
end
|
||||
end
|
||||
|
@ -87,8 +88,9 @@ module Handlers
|
|||
images = [item["urls"]["1"], item["urls"]["2"], item["urls"]["4"]]
|
||||
j.object do
|
||||
j.field "id", item["id"]
|
||||
j.field "name", item["name"]
|
||||
j.field "title", item["title"]
|
||||
# j.field "name", item["name"]
|
||||
# En FFZ remover "name" y que title sea el nuevo "name"
|
||||
j.field "name", item["title"]
|
||||
j.field "color", item["color"]
|
||||
j.field "urls" do
|
||||
j.array do
|
||||
|
|
|
@ -24,8 +24,15 @@ module Providers::Chatty
|
|||
next if item["id"] != "chatty"
|
||||
|
||||
item["usernames"].as_a.each_with_index do |username, index|
|
||||
if sql = SQL.query_one? "SELECT * FROM chatty_ids WHERE username = ? LIMIT 1", username.to_s, as: {String, String}
|
||||
item["usernames"].as_a[index] = JSON::Any.new(sql[1])
|
||||
puts "no"
|
||||
wg.done
|
||||
next
|
||||
end
|
||||
spawn do
|
||||
id = JSON::Any.new(Utils::GQL.new.get_user_id(username.to_s))
|
||||
SQL.exec "INSERT OR IGNORE INTO chatty_ids (username, twitch_id) VALUES (?, ?)", username.to_s, id.to_s
|
||||
item["usernames"].as_a[index] = id
|
||||
ensure
|
||||
wg.done
|
||||
|
|
|
@ -7,7 +7,7 @@ module Utils
|
|||
AND EXISTS (SELECT 1 FROM sqlite_schema WHERE type='table' AND name='seventv_ids');", as: Bool
|
||||
LOGGER.info "Creating sqlite3 database at '#{CONFIG.db}'"
|
||||
begin
|
||||
SQL.exec "CREATE TABLE IF NOT EXISTS seventv_ids (username text UNIQUE, twitch_id text UNIQUE, seventv_id text UNIQUE, )"
|
||||
SQL.exec "CREATE TABLE IF NOT EXISTS seventv_ids (username text UNIQUE, twitch_id text UNIQUE, seventv_id text UNIQUE)"
|
||||
SQL.exec "CREATE TABLE IF NOT EXISTS chatty_ids (username text UNIQUE, twitch_id text UNIQUE)"
|
||||
# SQL.exec "CREATE TABLE IF NOT EXISTS #{CONFIG.ipTableName} (ip text UNIQUE, count integer DEFAULT 0, date integer)"
|
||||
rescue ex
|
||||
|
|
Loading…
Reference in a new issue