-
Notifications
You must be signed in to change notification settings - Fork 0
Description
import requests
Replace 'YOUR_TELEGRAM_TOKEN' with your bot's API token
telegram_token = '607kXfGJDdyhE'
url = f'https://api.telegram.org/bot{telegram_token}/getUpdates'
response = requests.get(url)
data = response.json()
Retrieve the chat ID from the latest updates
for result in data['result']:
chat_id = result['message']['chat']['id']
print(f'Chat ID: {chat_id}')
break # We only need one chat ID
import requests
Replace 'YOUR_TELEGRAM_TOKEN' and 'YOUR_CHAT_ID' with your actual token and chat ID
telegram_token = '6076806604oi0RQykXfGJDdyhE'
chat_id = 'mm'
def send_telegram_message(message):
url = f'https://api.telegram.org/bot{telegram_token}/sendMessage'
payload = {
'chat_id': chat_id,
'text': message
}
response = requests.post(url, json=payload)
return response
Example: Send a notification
send_telegram_message('Process completed successfully!')
what i did wrong? please help
