Spaces:
Runtime error
Runtime error
File size: 873 Bytes
992705a 50f592c 992705a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import aiohttp
import asyncio
async def send_message_to_telegram(token, chat_id, message):
url = f"https://api.telegram.org/bot{token}/sendMessage"
async with aiohttp.ClientSession() as session:
params = {
'chat_id': chat_id,
'text': message
}
async with session.get(url, params=params) as response:
if response.status == 200:
print("Message sent successfully")
else:
print(f"Failed to send message: {response.status}")
# مثال لاستخدام الدالة
async def main():
token = '7865424971:AAF_Oe6lu8ZYAl5XIF1M6qU_8MK6GHWEll8'
chat_id = '227321236'
message = 'Hello, this is a test message from Hugging Face Space!'
await send_message_to_telegram(token, chat_id, message)
# تشغيل الدالة
asyncio.run(main()) |