Skip to content

dmitrijs-pavlovs-dev/whale-test

Repository files navigation

Telegram Whale Test Project (Nestjs, Svelte, PostgreSQL)

Alt whale-coding

This project is a Node.js-based Telegram bot designed to interact with users by providing a personalized greeting and administrative capabilities.

Demo

Preview this bot in telegram https://t.me/WhaleTestAppBot

Features

  • /start Command: Users can initiate interaction with the bot. The bot will respond with a message and a web app button that, when clicked, displays the user's first name as a greeting on a simple webpage.
  • /adminhello <telegram_id> <text> Command: Admins can send personalized messages to users by invoking this command followed by the user's Telegram ID and the intended message.
  • /getuserid <username> Admins can retrivies any telegram user id by providing telegram username
  • /makeadmin <userid> Admins can make other users an admin by providing telegram user id

Project Structure

The project follows a monorepo pattern and includes the following directories:

  • app/backend: Contains the Telegram bot source code.
  • app/web: A simple Svelte web application that greets users.
  • .github/workflows: Github deployment pipeline

Utilities

  • NestJS for the backend framework.
  • Telegraf for interacting with the Telegram Bot API.
  • TypeORM for database management.
  • Svelte for the web frontend.
  • Turbo for monorepo utilities.

Getting Started

Installation

Clone the repository and install dependencies:

git clone your-repo-link
cd your-repo-directory
yarn install

Configuration

TELEGRAM_BOT_TOKEN=XXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXX
TELEGRAM_WEBHOOK_DOMAIN=test.domain.net
POSTGRES_PASSWORD=pass
POSTGRES_USER=admin
POSTGRES_DB=db
POSTGRES_PORT=23423
POSTGRES_HOST=localhost
WEB_URL=http://dest.domain.net/

Running the bot

yarn dev

Build for production

yarn build

Deploying

The bot can be deployed on any Node.js compatible hosting service. For deployment, you have two options:

  1. Local Deployment: Configure the .env file and run the application using docker-compose.yml.

  2. Automated Deployment via GitHub Actions: Pushing to the main branch triggers a CI/CD pipeline that builds and pushes Docker images for the backend and web frontend, followed by deployment using Docker Compose on the remote server.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published