InterRep Telegram bot to allow users to join Semaphore Telegram groups.
npm install @interrep/telegram-bot
InterRep Telegram bot to allow users to join Semaphore Telegram groups.
The InterRep bot allows Telegram users to join corresponding Semaphore groups on InterRep. 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 InterRep does not save any ids.
---
Install the @interrep/telegram-bot package with npm:
``bash`
npm i @interrep/telegram-bot --save
or yarn:
`bash`
yarn add @interrep/telegram-bot
Before starting the bot you must configure the environment variables. Copy the .env.example file and rename it as .env:
`bash`
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:
`bash`
yarn start
\# new InterRepBot(token: _string_, mongodbUrl: _string_, appURL: _string_): _InterRepBot_
`typescript
import { InterRepBot } from "@interrep/telegram-bot"
const { TELEGRAM_BOT_TOKEN, MONGO_URL, APP_URL } = process.env
const bot = new InterRepBot(TELEGRAM_BOT_TOKEN, MONGO_URL, APP_URL)
await bot.start()
``