Fixed a bug where channels were being connected to when they weren't directories
authorGeorgios Atheridis <atheridis@tutamail.com>
Wed, 30 Mar 2022 16:22:33 +0000 (19:22 +0300)
committerGeorgios Atheridis <atheridis@tutamail.com>
Wed, 30 Mar 2022 16:22:33 +0000 (19:22 +0300)
aptbot/__main__.py
ttv_api/channel.py

index 0a620760b8c4f5fb15ca9795164054806e7a488e..e91adc9fd58840ec1131bc542f74d6fabc5ff819 100644 (file)
@@ -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:
index 260f2d7fef65ce1872f1bf78e4b9870e1ec657e3..790ae70ce14134a9e8e35f625ba395c6200c440c 100644 (file)
@@ -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(