diff --git a/src/handling.cr b/src/handling.cr index 732e735..9dfc36c 100644 --- a/src/handling.cr +++ b/src/handling.cr @@ -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 diff --git a/src/providers/chatty.cr b/src/providers/chatty.cr index 49fe2cf..002aa0e 100644 --- a/src/providers/chatty.cr +++ b/src/providers/chatty.cr @@ -24,16 +24,23 @@ 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 end end end - # Waits for all the fibers to complete before returning res + # Waits for all the fibers to complete before returning res wg.wait - return res + return res end end diff --git a/src/utils/utils.cr b/src/utils/utils.cr index f02e4c0..24340b6 100644 --- a/src/utils/utils.cr +++ b/src/utils/utils.cr @@ -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