- Brief Description
- Languages and Tools
- Project Details
- Docker version
- Installation Guide
- GitHub - Backend and Frontend
- Docker - Backend, Frontend and Application
- Shell script - Backend and Frontend
- Images
- This is a telegram bot project with several commands.
- Project link (GitHub): tele-bot-api
- DockerHub repository link: giaphuc/tele-bot-api
- Project's author: Pham Gia Phuc - Acus
- Personal profile: MyProfile
- JavaScript: Programming language
- NodeJS: JavaScript runtime environment
- ExpressJS: Web framework
- TelegrafJS: Modern Telegram Bot API framework for Node.js
- Docker: To dockerize and run on Docker platform
- MongoDB: Server database
- Postman: Testing tool
- Bash: Command-line execution
- ReactJS: The library for web and native user interfaces
- ViteJS: Frontend tool
- TailwindCSS: CSS framework
- HTML: The standard markup language for Web pages
- GitHub: Version control tool
This project is about Telegram Bot named @pgp_vn_bot that can be served as an admin bot in a Telegram group chat with serveral commands:
Bot commands:
- /start : 'Hi there ✋, please type /cmd to see the commands!'
- /check : check if the bot is listening
- /cmd : show the commands
- /addTele : add telegram member's username to database
- /addGitHub :add github member's username to database
- /allTeleMembers : print out all Telegram usernames
- /allGitMembers : print out all GitHub usernames
- /all: mention all people in the group chat
- /pdf: download a PDF file of group data
Bot messages: 'bot', 'hey there' and 'hey bot'`
Routes:
- For backend: http://localhost:8000 or http://localhost:8000/api/v1/member
- For frontend: http://localhost:8080 or http://localhost:8080/api/v1/member
Tag version | Description | OS | Architecture | Date | Link |
---|---|---|---|---|---|
1.0.0-backend | Backend side | Linux | amd64 | Sep 12, 2023 | Click here |
1.0.1-backend | Backend side | Linux | arm64, amd64 | Sep 12, 2023 | Click here |
1.0.0-frontend | Frontend side | Linux | amd64 | Sep 12, 2023 | Click here |
git clone [email protected]:phamgiaphuc/tele-bot-api.git
- Backend folder:
cd backend
- Frontend folder:
cd frontend
Step 3: Before executing the project, runs this command to install the following node_modules
and dependencies in the project
npm install
- Click this website and follow the instruction on
Register a Bot account
section
Create and Host a Telegram Bot with Node.js on Code Capsules
- Click this website and follow the instruction on
Get your cluster’s connection info
section in Connect to a MongoDB Database Using Node.js
PORT= // The port -> The default port is 3000
BOT_TOKEN= // The bot token after you create the Telegram bot
BOT_NAME= // Your bot name
BOT_USERNAME= // Your bot username
MY_CHAT_ID=[] // The chat id
MY_USERNAME= // Your Telegram username
MONGODB_USERNAME= // MongoDB username
MONGODB_PASSWORD= // MongoDB password
MONGODB_URL= // MongoDB url connection
- For backend:
npm start
- For frontend:
npm run dev
docker pull giaphuc/tele-bot-api:1.0.1-backend
- Click this website and follow the instruction on
Register a Bot account
section
Create and Host a Telegram Bot with Node.js on Code Capsules
- Click this website and follow the instruction on
Get your cluster’s connection info
section
docker run -it -p 8000:8000 -e PORT="$PORT" \
-e BOT_TOKEN="$BOT_TOKEN" \
-e BOT_NAME="$BOT_NAME" \
-e BOT_USERNAME="$BOT_USERNAME" \
-e MY_CHAT_ID="$MY_CHAT_ID" \
-e MY_USERNAME="$MY_USERNAME" \
-e MONGODB_USERNAME="$MONGODB_USERNAME" \
-e MONGODB_PASSWORD="$MONGODB_PASSWORD" \
-e MONGODB_URL="$MONGODB_URL" \
-v /path/to/host/directory:/root/Desktop \
--name "tele-bot-api-be" giaphuc/tele-bot-api:1.0.1-backend
Remember to change the host path before running the image
- http://localhost:8000
- http://localhost:8000/api/v1/test
- http://localhost:8000/api/v1/member
- http://localhost:8000/api/v1/member/telegram
- http://localhost:8000/api/v1/member/github
- http://localhost:8000/api/v1/member/:id
docker pull giaphuc/tele-bot-api:1.0.1-frontend
docker run -it -p 8000:8000 \
--name "tele-bot-api-fe" giaphuc/tele-bot-api:1.0.1-frontend
Remember to change the host path before running the image
version: '3'
services:
frontend:
container_name: tele-bot-api-frontend
image: giaphuc/tele-bot-api:1.0.0-frontend
ports:
- "8080:8080"
depends_on:
- backend
backend:
container_name: tele-bot-api-backend
image: giaphuc/tele-bot-api:1.0.1-backend
ports:
- "8000:8000"
volumes:
- /path/to/host/directory:/root/Desktop
environment:
- PORT='your_port'
- BOT_TOKEN='your_bot_token'
- BOT_NAME='your_bot_name'
- BOT_USERNAME='your_bot_username'
- MY_CHAT_ID='your_chat_id'
- MY_USERNAME='your_telegram_username'
- MONGODB_USERNAME='your_mongodb_username'
- MONGODB_PASSWORD='your_mongodb_password'
- MONGODB_URL='your_mongodb_url'
Make sure to replace 'your_port', 'your_bot_token', 'your_bot_name', 'your_bot_username', 'your_chat_id', 'your_telegram_username', 'your_mongodb_username', 'your_mongodb_password', 'your_mongodb_url' and host path with your actual values.
docker-compose up
- Backend:
- http://localhost:8000
- http://localhost:8000/api/v1/test
- http://localhost:8000/api/v1/member
- http://localhost:8000/api/v1/member/telegram
- http://localhost:8000/api/v1/member/github
- http://localhost:8000/api/v1/member/:id
- Frontend:
Step 1: Create a shell script or use the shell script in this repository and copy the below code to insert into the script
# Name: docker_run.sh
# !/bin/bash
# Pull the Docker image
docker pull giaphuc/tele-bot-api:1.0.1-backend
# Set your environment variables
PORT='your_port'
BOT_TOKEN='your_bot_token'
BOT_NAME='your_bot_name'
BOT_USERNAME='your_bot_username'
MY_CHAT_ID='your_chat_id'
MY_USERNAME='your_telegram_username'
MONGODB_USERNAME='your_mongodb_username'
MONGODB_PASSWORD='your_mongodb_password'
MONGODB_URL='your_mongodb_url'
# Run the Docker container
# Remember to change the host path before running the image
docker run -it -p 8000:8000 -e PORT="$PORT" \
-e BOT_TOKEN="$BOT_TOKEN" \
-e BOT_NAME="$BOT_NAME" \
-e BOT_USERNAME="$BOT_USERNAME" \
-e MY_CHAT_ID="$MY_CHAT_ID" \
-e MY_USERNAME="$MY_USERNAME" \
-e MONGODB_USERNAME="$MONGODB_USERNAME" \
-e MONGODB_PASSWORD="$MONGODB_PASSWORD" \
-e MONGODB_URL="$MONGODB_URL" \
-v /path/to/host/directory:/root/Desktop \
--name "TelegramBot" giaphuc/tele-bot-api:1.0.1-backend
Make sure to replace 'your_port', 'your_bot_token', 'your_bot_name', 'your_bot_username', 'your_chat_id', 'your_telegram_username', 'your_mongodb_username', 'your_mongodb_password', 'your_mongodb_url' and host path with your actual values.
2.1 Make the script executable by running the following command:
chmod +x docker_run.sh #Your shell file name
2.2 Run the script using:
./docker_run.sh #Your shell file name
Step 1: Create a shell script or use the shell script in this repository and copy the below code to insert into the script
# Name: docker_run.sh
# !/bin/bash
# Pull the Docker image
docker pull giaphuc/tele-bot-api:1.0.0-frontend
# Run the Docker container
# Remember to change the host path before running the image
docker run -it -p 8000:8000 \
--name "tele-bot-api-fe" giaphuc/tele-bot-api:1.0.0-frontend
2.1 Make the script executable by running the following command:
chmod +x docker_run.sh #Your shell file name
2.2 Run the script using:
./docker_run.sh #Your shell file name