0.2.0 • Published 3 years ago

@interep/telegram-bot v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

The Interep bot allows Telegram users to join corresponding Semaphore groups on Interep. If a user is for example a member of the Telegram group 'Hello world', the bot will send a magic link in their private chat that will allow them to join the Semaphore Telegram group 'Hello world' on our web application with Metamask.

When the bot sends the magic link (consisting of the user and group ids) it also saves a sha256 hash of the user and group ids with a flag to ensure that the magic link is correct in the application. The application will then be able to check whether the user redirected by the magic link is actually a user who has requested to join the group. The hash ensures that Interep does not save any ids.


🛠 Install

npm or yarn

Install the @interep/telegram-bot package with npm:

npm i @interep/telegram-bot --save

or yarn:

yarn add @interep/telegram-bot

📜 Usage

Start an interep bot

Before starting the bot you must configure the environment variables. Copy the .env.example file and rename it as .env:

cp .env.example .env

You can create a Telegram bot and obtain a token with @BotFather.

Once the environment variables have been set, start the bot with the npm start script:

yarn start

API

# new InterepBot(token: string, mongodbUrl: string, appURL: string): InterepBot

import { InterepBot } from "@interep/telegram-bot"

const { TELEGRAM_BOT_TOKEN, MONGO_URL, APP_URL } = process.env
const bot = new InterepBot(TELEGRAM_BOT_TOKEN, MONGO_URL, APP_URL)

await bot.start()