Template for Hydrogram bot - A pyrogram alternative
MIT License
This is a template for a Hydrogram bot using the Hyrogram framework a Pyrogram Alternative. Follow the steps below to set up and run the bot. For better developer experience install this code snippet extenstion.
Clone the Repository Clone this repository to your local machine using:
git clone https://github.com/nuhmanpk/hydrogram-bot.git
cd hydrogram-bot
Create a Virtual Environment Create a virtual environment to manage dependencies:
python3 -m venv venv
Activate the virtual environment:
On Windows:
venv\Scripts\activate
On macOS/Linux:
source venv/bin/activate
Install Dependencies Install the required Python packages:
pip install -r requirements.txt
Obtain Required Values You need to gather the following values to configure your bot:
Set Environment Variables Create a .env file in the root of your project directory and add the following content:
DATABASE_URL=your_mongodb_url
DATABASE_NAME=your_database_name
BOT_TOKEN=your_bot_token
API_ID=your_api_id
API_HASH=your_api_hash
Replace the placeholders (your_mongodb_url, your_database_name, your_bot_token, your_api_id, your_api_hash) with your actual values.
Run the Bot Finally, run the bot with:
python3 main.py
Install PM2 Install PM2, a process manager for Node.js applications that can also be used to manage Python processes:
sudo npm install pm2 -g
Start the Bot with PM2
pm2 start python3 --name hydrogram-bot -- main.py
pm2 startup
pm2 save
Monitor and Manage Your Bot You can manage your bot with PM2 using the following commands:
pm2 list
pm2 stop hydrogram-bot
pm2 restart hydrogram-bot
pm2 logs hydrogram-bot
Happy Coding ... 🚀