Skip to content

Commit

Permalink
Added comments to message.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-fatal committed Feb 11, 2023
1 parent ee2a4fa commit 92203bc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

def get_chat_id(token):
url = f"https://api.telegram.org/bot{token}/getUpdates"
data = requests.get(url).json()
data = requests.get(url).json() # Try find chat that user sent to our bot
try:
chat_id = data["result"][0]["message"]["chat"]["id"]
chat_id = data["result"][0]["message"]["chat"]["id"] # Retrieve chat id so we can reply
except IndexError:
return None
return str(chat_id)
Expand All @@ -14,4 +14,4 @@ def get_chat_id(token):
def send_message(token, chat_id):
message = "Your Solo Shuffle is ready."
url = f"https://api.telegram.org/bot{token}/sendMessage?chat_id={chat_id}&text={message}"
requests.get(url)
requests.get(url) # Send the message to the user

0 comments on commit 92203bc

Please sign in to comment.