From 15cb478ea77f27d474cd01934006e50f7370a094 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Wed, 30 Mar 2022 19:22:33 +0300 Subject: [PATCH] Fixed a bug where channels were being connected to when they weren't directories --- aptbot/__main__.py | 13 ++++++++----- ttv_api/channel.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/aptbot/__main__.py b/aptbot/__main__.py index 0a62076..e91adc9 100644 --- a/aptbot/__main__.py +++ b/aptbot/__main__.py @@ -43,9 +43,10 @@ def loop(bot: aptbot.bot.Bot, modules: dict[str, ModuleType]): def load_modules(modules: dict[str, ModuleType]): modules.clear() - channels = filter(lambda x: not x.startswith('.'), os.listdir(CONFIG_PATH)) - channels = list(channels) - # print(channels) + channels = [ + c for c in os.listdir(CONFIG_PATH) if os.path.isdir(os.path.join(CONFIG_PATH, c)) + ] + channels = filter(lambda x: not x.startswith('.'), channels) for channel in channels: account_path = os.path.join(CONFIG_PATH, f"{channel}") sys.path.append(account_path) @@ -71,7 +72,10 @@ def load_modules(modules: dict[str, ModuleType]): def initialize(bot: aptbot.bot.Bot): - channels = os.listdir(CONFIG_PATH) + channels = [ + c for c in os.listdir(CONFIG_PATH) if os.path.isdir(os.path.join(CONFIG_PATH, c)) + ] + channels = filter(lambda x: not x.startswith('.'), channels) for channel in channels: if not channel.startswith('.'): bot.join_channel(channel) @@ -81,7 +85,6 @@ def listener(): NICK = os.getenv("APTBOT_NICK") OAUTH = os.getenv("APTBOT_OAUTH") CLIENT_ID = os.getenv("APTBOT_CLIENT_ID") - print(f"NICK: {NICK}") if NICK and OAUTH and CLIENT_ID: bot = aptbot.bot.Bot(NICK, OAUTH, CLIENT_ID) else: diff --git a/ttv_api/channel.py b/ttv_api/channel.py index 260f2d7..790ae70 100644 --- a/ttv_api/channel.py +++ b/ttv_api/channel.py @@ -28,7 +28,7 @@ def get_channels(*channel_ids: str) -> Optional[list[Channel]]: return None data = json.loads(r.data.decode("utf-8"))["data"] - channels = [] + channels: list[Channel] = [] for channel in data: channels.append( -- 2.30.2