GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mixaboo/baraholkaBot: A bot that reads Telegram groups to quickly find useful information by keywords.

BranchesTags
Open more actions menu

Latest commit

 

History

54 Commits
54 Commits

Folders and files

NameName
Last commit message
Last commit date
.ai/mcp
.ai/mcp
 
 
.github/workflows
.github/workflows
 
 
data
data
 
 
src
src
 
 
test
test
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
.prettierrc
.prettierrc
 
 
Dockerfile
Dockerfile
 
 
README.md
README.md
 
 
docker-compose.yaml
docker-compose.yaml
 
 
eslint.config.mjs
eslint.config.mjs
 
 
nest-cli.json
nest-cli.json
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.build.json
tsconfig.build.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

Description

Telegram watcher-forwarder using:

  • MTProto user client (GramJS) to listen messages in a specific group without adding a bot to it;
  • Bot API (Telegraf) to forward matched messages into the bot chat with the admin.

Project setup

$ npm install

Required environment variables

Create a .env or export environment variables before running:

  • TELEGRAM_API_ID: your Telegram API ID (get from https://my.telegram.org)
  • TELEGRAM_API_HASH: your Telegram API hash (my.telegram.org)
  • TELEGRAM_PHONE: phone number of the user account that is a member of the target group (e.g. +79991234567)
  • TELEGRAM_2FA_PASSWORD: optional, if your account has 2FA enabled
  • TARGET_GROUPS: comma-separated list of target groups to watch. Each item can be @username, public link (https://t.me/...), numeric id, or exact title. Backward compatible: you can still set TARGET_GROUP with a single value.
    • To listen only a specific forum topic inside a group, append the topic id to the group using one of the following forms: @group#, @group/, or https://t.me// (e.g. https://t.me/detkinovisad/8). If a group is listed without a topic id, all its topics are listened.
  • BOT_TOKEN: Telegram bot token (used to chat with users and send them notifications)
  • SUBSCRIPTIONS_PATH: optional path to store per-user subscriptions (default: ./subscriptions.json)
  • TELEGRAM_SESSION_PATH: optional path to store session string (default: ./telegram.session)
  • LOG_FILE: optional path to write user actions log (default: ./logs/app.log)
  • TELEGRAM_KEEPALIVE_MS: optional keepalive interval in ms for user client (default: 60000)
  • TELEGRAM_USER_PROXY_URL: optional SOCKS4/SOCKS5 proxy URL for the GramJS user client, e.g. socks5://user:pass@host:1080. This is the recommended proxy for the user client. If set, it takes precedence over TELEGRAM_MTPROXY_URL.
  • TELEGRAM_MTPROXY_URL: optional classic MTProxy URL for the GramJS user client, e.g. tg://proxy?server=host&port=8443&secret=secret. Fake-TLS/telemt ee... secrets are not supported by GramJS in this project.
  • TELEGRAM_BOT_PROXY_URL: optional HTTP/HTTPS proxy URL for Telegraf Bot API requests, e.g. http://host:3128. If the scheme is omitted, http:// is used.
  • TELEGRAM_PROXY_TIMEOUT_SECONDS: optional user-client proxy connection timeout in seconds (default: 10)

Example:

export TELEGRAM_API_ID=123456
export TELEGRAM_API_HASH=abcdef0123456789abcdef0123456789
export TELEGRAM_PHONE=+381062943234
# multiple groups (comma-separated) or use TARGET_GROUP for single
# You can also target a specific forum topic using @group#<topicId> or a t.me/<username>/<topicId> link
export TARGET_GROUPS=@my_public_group,https://t.me/detkinovisad/8
export BOT_TOKEN=123456:AA...token
# optional, recommended: SOCKS5 proxy for reading groups through GramJS/MTProto
export TELEGRAM_USER_PROXY_URL=socks5://user:[email protected]:1080
# optional fallback: classic MTProxy for GramJS/MTProto. Do not use telemt/fake-TLS ee... secrets here.
# export TELEGRAM_MTPROXY_URL='tg://proxy?server=proxy.example.com&port=8443&secret=classic_16_byte_hex_secret'
# optional: Squid/HTTP proxy for Telegraf Bot API
export TELEGRAM_BOT_PROXY_URL=http://proxy.example.com:3128
# optional: where to store per-user subscriptions
export SUBSCRIPTIONS_PATH=./subscriptions.json
# optional: path for storaging a session file
export TELEGRAM_SESSION_PATH=./telegram.session

First run will ask for a login code (and 2FA password if enabled) in the console, then it will save a session file to avoid further prompts.

Persistence and logs

  • Session file: set TELEGRAM_SESSION_PATH or rely on default ./telegram.session. In Docker, it is mounted to the host to survive restarts.
  • Subscriptions: stored in JSON file at SUBSCRIPTIONS_PATH (default ./subscriptions.json); mount it on host to persist.
  • Logs: user actions are written to LOG_FILE (default ./logs/app.log). Mount ./logs to persist logs.

docker-compose.yaml already mounts:

  • ./telegram.session -> /app/telegram.session
  • ./subscriptions.json -> /app/subscriptions.json
  • ./logs -> /app/logs

So by default, everything is persisted outside of the container.

How it works

  • A user client (MTProto) connects using your phone account and listens to new messages in the configured group.
  • On /start the bot asks each user for their keywords and stores them.
  • For every new message, the service checks each user’s keywords and sends a notification only to users with a match.

Note: This approach is required because the bot cannot be added to the group. Reading group messages requires a user account that is a member of that group.

Compile and run the project

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Run tests

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

About

A bot that reads Telegram groups to quickly find useful information by keywords.

Topics

nestjstelegrambot

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.