Skip to content

Commit

Permalink
Merge pull request #11 from YeetCode-devs/staging/hakimi
Browse files Browse the repository at this point in the history
Relative import, reformat, guard credentials, satisfy type checker
  • Loading branch information
prathamdby authored Mar 18, 2024
2 parents e4cf061 + 41b8fd9 commit 85e8ac9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
22 changes: 13 additions & 9 deletions src/Bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion src/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from Bot import main
from .Bot import main

if __name__ == "__main__":
main()
6 changes: 4 additions & 2 deletions tests/test_bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand All @@ -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...")
Expand Down

0 comments on commit 85e8ac9

Please sign in to comment.