├── README.md ├── main.py └── requirements.txt /README.md: -------------------------------------------------------------------------------- 1 | # Simple bot for : Send file from vps/host to admin by Telegram Bot :sunglasses: 2 | **please give me star:star:** 3 | 4 | 5 | **Do these things first : :point_down:** 6 | 7 | ``` 8 | pip install -r requirements.txt 9 | ``` 10 | 11 | **Then : :point_down:** 12 | 13 | - Open the main file 14 | - Add your api id 15 | - Add your api hash 16 | - Add your bot token 17 | - Add file path 18 | - Setting the time to send 19 | - Run main.py 20 | 21 | My id in telegram [SardarCyberym](https://t.me/Oxygn16) :speech_balloon: 22 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from telethon import TelegramClient 2 | from os import path 3 | from telethon.tl.types import PeerUser 4 | from typing import Optional 5 | import asyncio 6 | import logging 7 | 8 | 9 | logging.basicConfig(filename="log.txt", filemode="a",format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) 10 | logger = logging.getLogger(__name__) 11 | 12 | 13 | config = { 14 | "apiID": 123, 15 | "apiHash": "", 16 | "botToken": "", 17 | "directory": r"./log.txt", 18 | "adminUserId": 2056493966, 19 | } 20 | 21 | 22 | async def main() -> None: 23 | 24 | client = TelegramClient( 25 | session="bot", 26 | api_id=config["apiID"], 27 | api_hash=config["apiHash"] 28 | ) 29 | 30 | await client.start(bot_token=config["botToken"]) 31 | 32 | if not check_file(): 33 | print("File does not exist.") 34 | return 35 | 36 | try: 37 | await client.send_file(PeerUser(config["adminUserId"]), config["directory"], caption='with love ⚡️') 38 | print("File sent successfully.") 39 | except Exception as ex: 40 | print(f"An error occurred: {ex}") 41 | finally: 42 | await client.disconnect() 43 | 44 | def check_file(dir: Optional[str] = config.get('directory', None)) -> bool: 45 | 46 | return (dir and path.exists(dir)) 47 | 48 | if __name__ == "__main__": 49 | asyncio.run(main()) 50 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | aiocron==1.8 2 | Telethon==1.27.0 --------------------------------------------------------------------------------