Group Message Collector is a robust Telegram bot that helps you manage and organize messages within your Telegram groups. By capturing and storing messages, user details, and group information in a structured database, it provides a seamless way to keep track of your community’s conversations.
- Message Logging: Automatically logs and organizes all messages from your group chats.
- User Management: Tracks user properties and stores them in a dedicated table for easy access.
- Group Details: Captures group-specific attributes, helping you manage multiple groups effortlessly.
- Efficient Data Retrieval: Utilizes relational database models to facilitate quick and efficient data queries.
- Admin Commands: Includes special commands for admins to manage and retrieve data.
- Python 3.7+: Make sure you have Python installed on your machine. You can download it from python.org.
- Telegram Bot: You need a Telegram bot token from BotFather. Follow the instructions to create your bot and get the token.
Open your terminal and navigate to the directory where you want to store the bot's code. Then run:
git clone https://github.com/xectrone/group-message-collector-telegram-bot.git
Navigate into the cloned directory:
cd group-message-collector-telegram-bot
Ensure you are in the project directory and then install the necessary Python packages:
pip install -r requirements.txt
Create a .env
file in the project directory with the following content, replacing the placeholders with your actual Bot Token and Admin IDs:
BOT_TOKEN='YOUR_BOT_TOKEN'
ADMIN_IDS='ID_1,ID_2,ID_3'
Start the bot by running the following command:
python bot.py
In the BotFather chat, use the /setprivacy
command, select your bot, and choose "Disable". This setting allows the bot to read all messages in the group, which is necessary for it to log them.
/start
- Start the bot and get a welcome message./help
- Display all available commands and their descriptions./all_users
- (Admin) Get a list of all users tracked by the bot./msgs <UserID>
- (Admin) Retrieve the last 4 messages from a specified user.
Admin commands require the sender to be listed in the ADMIN_IDS
in the .env
file. This ensures that only authorized users can access sensitive information and administrative features.
Contributions are welcome! If you have any ideas, suggestions, or improvements, feel free to submit a pull request or open an issue on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for more details.