diff --git a/src/Bot.py b/src/Bot.py index 87fcdb9..8de4032 100644 --- a/src/Bot.py +++ b/src/Bot.py @@ -2,17 +2,21 @@ from telethon import TelegramClient, events from os import getenv + def main() -> None: - load_dotenv() + load_dotenv() + + api_id = getenv("API_ID", 0) + api_hash = getenv("API_HASH", "") + bot_token = getenv("BOT_TOKEN", "") - api_id = getenv("API_ID") - api_hash = getenv("API_HASH") - bot_token = getenv("BOT_TOKEN") + if not all([api_id, api_hash, bot_token]): + raise ValueError("Could not get all required credentials from env!") - app = TelegramClient('app', api_id, api_hash).start(bot_token=bot_token) + app = TelegramClient("app", int(api_id), api_hash).start(bot_token=bot_token) - @app.on(events.NewMessage(incoming=True, pattern='/start')) - async def start(event): - await event.reply("Hello!") + @app.on(events.NewMessage(incoming=True, pattern="/start")) + async def start(event): + await event.reply("Hello!") - app.run_until_disconnected() + app.run_until_disconnected() diff --git a/src/__main__.py b/src/__main__.py index 59b177a..a3adb55 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -1,4 +1,4 @@ -from Bot import main +from .Bot import main if __name__ == "__main__": main() diff --git a/tests/test_bing.py b/tests/test_bing.py index b30337d..64aec6d 100644 --- a/tests/test_bing.py +++ b/tests/test_bing.py @@ -24,7 +24,9 @@ def generate_response() -> str: try: response = client.chat.completions.create( model="gpt-4.0-turbo", - messages=[{"role": "user", "content": "Say hi, with your response starting with START and ending with END"}], + messages=[ + {"role": "user", "content": "Say hi, with your response starting with START and ending with END"} + ], ) except: print("ERROR: Could not create a prompt!") @@ -36,7 +38,7 @@ class TestOutput: def test_output(self): response = generate_response() - if (len(response) > 0): + if len(response) > 0: print("✅ Bing is up!") else: print("❌ Bing is down...")