0.1.7 • Published 4 years ago

telegraf-wiretapper v0.1.7

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Telegraf Wire Tapper

Telegraf middleware for those who tired to read over9000 unread chat messages and prefer to listen it as a podcast.

Installation

$ npm install telegraf-wiretapper

Usage

Yandex SpeechKit cloud API

This middleware uses Yandex SpeechKit to synthesize messages. You should have Yandex cloud account to access API. Middleware configuration requires Yandex cloud folder id and access key. Please follow official documentation to setup it properly.

FFmpeg

Your bot host should have FFmpeg installed.

Session

The middleware usess Telegraf session object as a storage. You can choose any implementation to make it statefull.

Important: use chat id as a session key (see bot example below).

Bot example

import Telegraf, { ContextMessageUpdate } from 'telegraf';
import { WireTapper, Configuration } from 'telegraf-wiretapper';
import LocalSession from 'telegraf-session-local';

const botToken = process.env.BOT_TOKEN || 'your bot token';
const config: Configuration = {
  playCommand: 'play',
  yandexCloud: {
    accessKey: process.env.YANDEX_CLOUD_ACCESS_KEY || 'Yandex cloud access key',
    folderId: process.env.YANDEX_CLOUD_FOLDER_ID || 'Yandex cloud folder'
  }
};

const localSession = new LocalSession(
  {
    getSessionKey: (ctx: ContextMessageUpdate) => ctx.chat!.id
  }
)

const bot = new Telegraf(botToken);
const wireTapper = new WireTapper(config);

bot.use(
  localSession.middleware(),
  wireTapper.middleware()
);

bot.launch();

Docker example

Below is Dockerfile I used to run it:

FROM node
RUN apt-get update && apt-get install -y ffmpeg

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install
COPY . .
CMD [ "npm", "start" ]

then run it using command:

docker run <your bot image> -d --env BOT_TOKEN=<your bot token> --env YANDEX_CLOUD_FOLDER_ID=<id of Yandex cloud folder> --env YANDEX_CLOUD_ACCESS_KEY=<Yandex cloud access key>
0.1.7

4 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago