Giter Site home page Giter Site logo

phamgiaphuc / tele-bot-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 847 KB

Telegram Bot that can be served as an admin bot in a Telegram group chat with several commands

JavaScript 94.05% HTML 1.44% Dockerfile 2.36% Shell 2.01% CSS 0.13%
javascript nodejs telegrafjs telegram-bot-api docker reactjs tailwindcss

tele-bot-api's Introduction

Telegram Bot API

Contents


Brief Description

  • 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

Languages and Tools in this project

  1. JavaScript: Programming language
  2. NodeJS: JavaScript runtime environment
  3. ExpressJS: Web framework
  4. TelegrafJS: Modern Telegram Bot API framework for Node.js
  5. Docker: To dockerize and run on Docker platform
  6. MongoDB: Server database
  7. Postman: Testing tool
  8. Bash: Command-line execution
  9. ReactJS: The library for web and native user interfaces
  10. ViteJS: Frontend tool
  11. TailwindCSS: CSS framework
  12. HTML: The standard markup language for Web pages
  13. GitHub: Version control tool

Project Details

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:

  1. /start : 'Hi there ✋, please type /cmd to see the commands!'
  2. /check : check if the bot is listening
  3. /cmd : show the commands
  4. /addTele : add telegram member's username to database
  5. /addGitHub :add github member's username to database
  6. /allTeleMembers : print out all Telegram usernames
  7. /allGitMembers : print out all GitHub usernames
  8. /all: mention all people in the group chat
  9. /pdf: download a PDF file of group data

Bot messages: 'bot', 'hey there' and 'hey bot'`

Routes:

Docker version

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

Installation Guide

1. GitHub:

Step 1: Git clone this repository to your local computer and go to which folder you want to run

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

Step 4: Create the Telegram Bot Token and MongoDB url

  • 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

Connect to a MongoDB Database Using Node.js

Step 3: Create .env file and add the environmnet variables

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

Step 4: Apply this command to run the project

  • For backend:
npm start
  • For frontend:
npm run dev

2. Docker

A. Backend

Step 1: Docker pull this image to your local computer

docker pull giaphuc/tele-bot-api:1.0.1-backend

Step 2: Create the Telegram Bot Token and MongoDB url

  • 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

Connect to a MongoDB Database Using Node.js

Step 3: Add environment variables and docker run this 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 "tele-bot-api-be" giaphuc/tele-bot-api:1.0.1-backend

Remember to change the host path before running the image

Step 4: Backend routes

B. Frontend

Step 1: Docker pull this image to your local computer

docker pull giaphuc/tele-bot-api:1.0.1-frontend

Step 2: Docker run this image

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

Step 3: Frontend routes

C. Application (Both backend and frontend)

Step 1: Create a docker-compose.yml file and copy the below code to insert into the script

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.

Step 2: Run the below command

docker-compose up

Step 3: Routes

  1. Backend:
  1. Frontend:

3. Shell script

A. Backend

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.

Step 2: To run the script, follow these steps

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

B. 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.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

Step 2: To run the script, follow these steps

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

tele-bot-api's People

Contributors

acuspgp avatar phamgiaphuc avatar

Watchers

 avatar

Forkers

lusficer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.