Skip to content

Commit

Permalink
🦋TwitchIDs are strings now
Browse files Browse the repository at this point in the history
  • Loading branch information
Aluerie committed Nov 16, 2024
1 parent 1017d08 commit 77dd1f3
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ext/fpc/base_classes/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .models import BaseMatchToEdit, BaseMatchToSend

class GetTwitchLivePlayerRow(TypedDict):
twitch_id: int
twitch_id: str
player_id: int

class ChannelSpoilQueryRow(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion ext/fpc/base_classes/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def account_string(self) -> str:

async def set_base_attrs(self, bot: AluBot) -> None:
if self.is_twitch_streamer:
twitch_user = next(iter(await bot.twitch.fetch_users(names=[self.player_name])), None)
twitch_user = next(iter(await bot.twitch.fetch_users(logins=[self.player_name])), None)
if not twitch_user:
msg = f"Error checking twitch user `{self.player_name}`.\n User either does not exist or is banned."
raise errors.BadArgument(msg)
Expand Down
4 changes: 2 additions & 2 deletions ext/fpc/dota/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(
hero_ids: list[int],
server_steam_id: int,
player_hero: Hero | PseudoHero,
twitch_id: int | None = None,
twitch_id: str | None = None,
) -> None:
super().__init__(bot)
self.match_id: int = match_id
Expand All @@ -63,7 +63,7 @@ def __init__(
self.player_hero: Hero | PseudoHero = player_hero
self.hero_ids: list[int] = hero_ids
self.server_steam_id: int = server_steam_id
self.twitch_id: int | None = twitch_id
self.twitch_id: str | None = twitch_id

@property
def links(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion ext/fpc/dota/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FindMatchesToEditQueryRow(TypedDict):
class AnalyzeTopSourceResponsePlayerQueryRow(TypedDict):
player_id: int
display_name: str
twitch_id: int
twitch_id: str

class GetRecipientsQueryRow(TypedDict):
channel_id: int
Expand Down
2 changes: 1 addition & 1 deletion ext/fpc/lol/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(

self.game_name: str = player_account_row["game_name"]
self.tag_line: str = player_account_row["tag_line"]
self.twitch_id: int = player_account_row["twitch_id"]
self.twitch_id: str = player_account_row["twitch_id"]

self.start_time: int = game.get("gameStartTime", 0)
self.all_champion_ids: list[int] = [p["championId"] for p in game["participants"]]
Expand Down
2 changes: 1 addition & 1 deletion ext/fpc/lol/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LivePlayerAccountRow(TypedDict):
tag_line: str
platform: str
display_name: str
twitch_id: int
twitch_id: str
last_edited: int

class FindMatchesToEditQueryRow(TypedDict):
Expand Down
2 changes: 1 addition & 1 deletion sql/fpc_dota.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS dota_settings (
CREATE TABLE IF NOT EXISTS dota_players (
player_id SERIAL PRIMARY KEY,
display_name TEXT NOT NULL,
twitch_id BIGINT NOT NULL UNIQUE
twitch_id TEXT NOT NULL UNIQUE
);

CREATE TABLE IF NOT EXISTS dota_favourite_players (
Expand Down
2 changes: 1 addition & 1 deletion sql/fpc_lol.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS lol_settings (
CREATE TABLE IF NOT EXISTS lol_players (
player_id SERIAL PRIMARY KEY,
display_name TEXT NOT NULL,
twitch_id BIGINT NOT NULL UNIQUE
twitch_id TEXT NOT NULL UNIQUE
);

CREATE TABLE IF NOT EXISTS lol_favourite_players (
Expand Down
2 changes: 1 addition & 1 deletion utils/twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def irene(self) -> twitchio.PartialUser:
"""Get Irene's channel from the cache."""
return self.create_partialuser(const.TwitchID.Me)

async def fetch_streamer(self, twitch_id: int) -> Streamer:
async def fetch_streamer(self, twitch_id: str) -> Streamer:
user = await self.create_partialuser(twitch_id).user()
stream = next(iter(await self.fetch_streams(user_ids=[twitch_id])), None) # None if offline
return Streamer(self, user, stream)
Expand Down

0 comments on commit 77dd1f3

Please sign in to comment.