Skip to content

darkuser21/Teligram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Teligram-bot

Telegram bot that is used to print data from the mango db database

๐Ÿ“ž Telegram Bot with MongoDB Search

This is a Telegram bot that allows users to search a MongoDB database using a mobile number.
If the number exists, the bot returns all associated details.
If not, it replies with "โŒ Data not found."


๐Ÿš€ Features

  • ๐Ÿ” Search MongoDB using a mobile number (_id)
  • โœ… Handles errors gracefully
  • ๐Ÿ›  Easy to set up and deploy
  • ๐Ÿ”„ Automatically reconnects to MongoDB

๐Ÿ“Œ Setup & Installation

1๏ธโƒฃ Clone the Repository

git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name

2๏ธโƒฃ Install Dependencies##

pip install -r requirements.txt

3๏ธโƒฃ Create a .env File

Create a .env file in the project directory and add your credentials:

BOT_TOKEN=your-telegram-bot-token
MONGO_URI=mongodb://localhost:27017/
DB_NAME=your_database_name
COLLECTION_NAME=your_collection_name

4๏ธโƒฃ Run the Bot

Copy code
python bot.py

๐ŸŽฎ How to Use 1๏ธโƒฃ Start the Bot

Send /start to see a welcome message.

2๏ธโƒฃ Search a Number

Send a mobile number (e.g., 9692307299) to search in the database.

3๏ธโƒฃ Response Examples If found:

โœ… Data Found: ๐Ÿ”น Name: John Doe ๐Ÿ”น Email: johndoe@example.com ๐Ÿ”น City: New York

If not found: โŒ Data not found.

โš™๏ธ Deployment (Optional) Deploy on a Linux Server (Auto-Restart) Run the bot using screen

screen -S telegram-bot
python bot.py
Press CTRL + A, then D to detach.

To restart the bot automatically if it crashes, use:

while true; do python3 bot.py; sleep 5; done

๐Ÿ›  Troubleshooting Bot not responding? Check if BOT_TOKEN is correct. Ensure MongoDB is running (systemctl start mongod). MongoDB connection error? Verify MONGO_URI in .env file.

๐Ÿค Contributing Fork the repo Create a new branch (git checkout -b feature-branch) Commit changes (git commit -m "Added feature") Push (git push origin feature-branch) Open a Pull Request ๐Ÿš€

๐Ÿ“œ License This project is open-source under the MIT License.

โญ๏ธ Show Some Love! If you found this project useful, give it a star โญ๏ธ on GitHub!

About

Telegram bot that is used to print data from the mango db database

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages