david1602 / 1337

A telegram bot that will manage postings of 1337 and do a few more things.
0 stars 0 forks source link

1337

About

This bot was intentionally meant to keep track of us making certain posts at a certain time on telegram. Any custom commands can however be added and this can be expanded. This bot is not meant for anything large-scale as it caches a big part of the database internally to avoid sending too many database requests. The cache is persisted in the database so that the bot can load it again if it's restarted and no data is lost.

In addition, this bot is only meant to work within one chat at a time.

Setup

Dependencies

Install them.

npm install

Update your configuration file

Copy config.js.template to config.js and fill out your data. The dbConn object is ready to use for knex, however, the dbConn.connection is relevant for pg-promise. The token is the token you receive from @BotFather on Telegram. Along with that, you can add an ownerid which can be a ID of a telegram user (probably yourself as administrator) who is the only person to execute certain commands.

Set up the database

Create the database and a role with password and login permission. Make sure you use the credentials you used in the configuration. Also give the ownership to that role.

CREATE DATABASE telegramstuff;
CREATE ROLE telegrambot WITH PASSWORD 'password' LOGIN;
ALTER DATABASE telegramstuff OWNER TO telegrambot;

Set up the tables

Either connect to the database and execute the setup.sql script or run node setup.js in the root folder which will connect to the database and do the same.