Skip to content

A Telegram bot that registers messages (media, video, photo, text) and schedule a timer to send the stored messages on groups.

Notifications You must be signed in to change notification settings

luisfmnunes/JackBotTelegram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Message Scheduler Bot (Jack)

Jack is a Telegram Bot developed using Typescript. His purpose is to provide an enviroment to store messages (announcements, reminders, etc) and broadcast them among registered groups.

Installation

Jack is made with Typescript, so Node.js is used to deal with initialization and dependencies. The version of node used is v14.16.1 with npm version v6.14.12.

Project dependencies can be installed with command:

npm install

Configuration

The configuration of the bot is made by environment variables, with can be manually inserted (in case of Linux with export command) or using a .env file. The variables required are the following:

  • BOT_TOKEN: The Token generated by the Telegram Bot Father

  • DATABASE_URL: The URL used to connect to the database (required by prisma)

  • PORT: The port in which the server will be listening

Initialization

The initialization may be performed in two different ways, either by compiling the Typescript code (which by tsconfig.json outDir will be compiled to dist folder) with the following command:

npx tsc

node dist/index.js

Or it can be done with the dependency ts-node-dev that starts a server to monitor the project files, restarting the application with any changes applied and saved to files. The dependency can be used in the following command:

npx ts-node-dev src/index.ts

Prisma

Prisma is used to manage the Relational Database (postgresql used), dealing with migrations and basic operations (querys, insertions, etc). So the prisma CLI (Command Line Interface) is recommended in order to call prisma commands.

To start a table in the database provided (contained on the DATABASE_URL environt variable) a migration is necessary. The following commands provides the migration execution.

  • Development
npx prisma migrate dev --name NAME_OF_MIGRATION
  • Production and Testing Environments
npx prisma migrate deploy

Usage

After performing the previous steps, talking to the bot through commands allows to use the bot accordingly to the desired purpose. The main steps are registering chats and adding messages for posting.

Add Command Del Command

Commands

Currently there are five available commands as described below:

  • comandos: List all available commands of the bot

  • register: Registers a group chat id for redistribution of messages (called on group)

  • add: Starts the add wizard to add a message. The steps are the following:

    1. Send the Message or forward a Message to be stored

    2. Inform the period which the message will be distributed. Accepted formats:

      • number ( in minutes ) | e.g. 10
      • number + m | e.g. 15m
      • number + h | e.g. 1h
      • number + h + number ( in minutes ) | e.g. 1h20
      • number + h + number + m | e.g. 2h30m
    3. Preview displayed asking to confirm the message or restart the process

    4. Confirmation of message registration

  • del: Deletes a single message. Available messages are displayed on keyboard.

  • update: Updtates a single message. Available messages are displayed on keyboard.

  • clear: Clear all messages stored

Upcoming Changes

  • Support to Language Selection (currently only supports PT-BR)
  • Removal of messages given Date argument
  • Update of specific message
  • Selection of Groups for distribution

About

A Telegram bot that registers messages (media, video, photo, text) and schedule a timer to send the stored messages on groups.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published