- Creating a Bot on Telegram
- Creating an App on Telegram
- Cloning the Repository
- Setting Up the Workspace
- Running the Bot
- Project Structure
- Notes
- Open Telegram and go to BotFather.
- Start the BotFather bot and send the command:
/newbot
. - Follow the instructions to name your bot and set a username.
- BotFather will provide you with an API token. Keep this token for the next steps.
Open your web browser and go to my.telegram.org.
Log in using your phone number. You will receive a confirmation code in the Telegram app, which you need to enter on the website.
After logging in, you will see the "API Development Tools" section. Click on it to proceed.
You will be prompted to create a new application. Fill in the required fields:
- App title: The name of your application.
- Short name: A short identifier for your application.
- URL: Enter a placeholder URL if you don't have a public URL, such as http://example.com.
- Platform: Select the platform your application will run on (e.g., Desktop, Web, Android, iOS).
- Description: A brief description of your application.
Here’s an example of how you might fill out the form:
- App title: MyTelegramApp
- Short name: mytelegramapp
- URL: http://example.com
- Platform: Desktop
- Description: This is a test application for interacting with the Telegram API.
After filling out the form, click the "Create Application" button.
Once the application is created, you will be redirected to a page displaying your application's details, including your API ID and API hash. These credentials are essential for interacting with the Telegram API.
- Install Git from Installing Git.
- Install Python from Installing Python.
- Create a new folder on your system.
- Open PowerShell in the new folder (Shift + Right-click > Open PowerShell window here).
- Open the folder in your code editor:
code .
- In the terminal, clone the repository:
git clone https://github.com/Fanboy041/GroupManager.git
- Install the required libraries by running:
pip install -r requirements.txt
- Create a
.env
file in the root directory with the following content:Replace the placeholders with your MongoDB URI, api hash, api id also the bot API token from BotFather.MONGO_URI="" BOT_TOKEN="" API_HASH='' API_ID=''
To start the bot, run:
python ./src/main.py
Or to start with a watcher that restarts the bot if script modified, run:
python ./src/watcher.py ./src/main.py
If you're using Termux, you need to add the following to the main script:
import dns.resolver
dns.resolver.default_resolver=dns.resolver.Resolver(configure=False)
dns.resolver.default_resolver.nameservers=['8.8.8.8']
- requirements.txt: Lists the required libraries.
- src:
- Commands: Scripts for bot commands (e.g.,
/start
). - Database: Scripts for database interactions with MongoDB.
- Features: Additional features for the bot.
- Buttons: Scripts for handling callback queries (actions triggered by inline buttons).
- main.py: The main script that integrates all components.
- Commands: Scripts for bot commands (e.g.,
- Let commands controls the bot functionality
- Recreate the database to match Walid's thoughts
- Do not make a lot of decorators in the main.py file
- Do not make decorators inside functions