This project implements a Telegram bot using the Pyrogram library for interacting with the Telegram API. The bot is designed to handle messages in a specific chat, download media files, and store text messages in a CSV file.
The primary purpose of this Telegram bot is to provide a convenient way to manage and store media and text messages from a designated chat. It can be used to automate certain tasks or log interactions within the specified Telegram environment.
Before you begin, ensure you have met the following requirements:
- Python 3.x installed on your system.
- A Telegram account.
- Telegram API credentials (API_ID and API_HASH), which can be obtained by creating a Telegram application at Telegram Apps.
- A bot token and a designated chat name for interaction.
- Clone the Repository:
git clone https://github.com/PrantaDas/telegram-insight-spy-bot.git cd telegram-insight-spy-bot
- Create a .env file in the project root with the following environment variables:
API_ID=your_telegram_api_id API_HASH=your_telegram_api_hash PHONE_NUMBER=your_phone_number PASSWORD=your_telegram_account_password BOT_NAME=your_bot_name CHAT_NAME=your_designated_chat_name
- Install Dependencies:
pip install -r requirements.txt
- Run the bot:
python src/main.py
- bot.py: Contains the Pyrogram client instance and the message handler.
- utils.py: Utility functions for checking environment variables, creating directories, and writing messages to CSV.
- main.py: Script to run the bot and handle exceptions.
The bot is configured to run with the specified environment variables and handles media and text messages in the designated chat.
he main.py script catches specific exceptions related to Pyrogram errors (Unauthorized, BadRequest, Forbidden) and general exceptions.
Feel free to contribute to the project by opening issues or submitting pull requests.
Made with ❤️ by Pranta Das.