-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (21 loc) · 674 Bytes
/
Copy pathapp.py
File metadata and controls
28 lines (21 loc) · 674 Bytes
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
26
import asyncio
import os
import sys
import requests
from telegram import Bot
from Setting import bot_token,chat_id
async def send_file_to_telegram_bot(bot_token, chat_id, file_path):
"""
Sends a file to a user in Telegram using a Telegram bot.
"""
bot = Bot(token=bot_token)
with open(file_path, 'rb') as file:
await bot.send_document(chat_id=chat_id, document=file) # Await the send_document coroutine
async def main():
"""
Main function to send file to a user in Telegram .
"""
save_path = sys.argv[1]
await send_file_to_telegram_bot(bot_token, chat_id, save_path)
if __name__ == "__main__":
asyncio.run(main())