Catalog npm
Back to packageRELEASE DETAILS

1.0.5

npm

11ff

[![Version](https://img.shields.io/npm/v/cfworker-middware-telegraf.svg?style=flat-square)](https://www.npmjs.com/package/cfworker-middware-telegraf)

Published1 Mar 2021
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

cfworker-middware-telegraf

Version

Make telegraf (a telegram bot framework) useable in Cloudflare Workers.

Installation

npm i cfworker-middware-telegraf

Usage

1. Write your code

// index.js
const { Telegraf } = require('telegraf');
const { Application, Router } = require('@cfworker/web');
const createTelegrafMiddware = require('cfworker-middware-telegraf');

const bot = new Telegraf('BOT_TOKEN');

// Your code here, but do not `bot.launch()`

const router = new Router();
router.post('/SECRET_PATH', createTelegrafMiddware(bot));
new Application().use(router.middleware).listen();

2. Webpack your code and upload to cfworker

// webpack.config.js
module.exports = {
  target: 'webworker',
  entry: './index.js',
  mode: 'production',
  node: {
    fs: 'empty',
  },
  module: {
    rules: [
      {
        test: /\.mjs$/,
        include: /node_modules/,
        type: 'javascript/auto',
      },
    ],
  },
  performance: {
    hints: false,
  },
};

Just copy and paste built code to cfworker online editor and save.

Or you can use Wrangler, an official CLI tool, so you don't need to copy and paste code manually anymore. But I don't like it due to its inexplicable bugs on Win10.

3. Set telegram bot webhook

These codes only need to be run once locally.

const Telegraf = require('telegraf');
const bot = new Telegraf('BOT_TOKEN');

// set webhook
bot.telegram.setWebhook('https://your.cfworker.domain/SECRET_PATH');

// delete webhook
// bot.telegram.deleteWebhook();

// get webhook info
// bot.telegram.getWebhookInfo().then(console.log);

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-fcHh0dScIbIuvyLQ6DDwaWIglinXJNtc5BYfTs3RpCPy1W6ZdyMxkWGiX1y5ohsbZmQ1GKZ1LgPqr0OfCmpYZw==",
  "shasum": "6edf60f6851309226b22666981d2c71da367e34f",
  "tarball": "https://registry.npmjs.org/11ff/-/11ff-1.0.5.tgz",
  "fileCount": 7,
  "unpackedSize": 9791,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgPVePCRA9TVsSAnZWagAAYiAP/RWs8hjMQR2ycgKUZwkV\nyqPGt0HpVpTrkYxKce32o9Tg5HfdUIdWSsfOgW2Zr0Uz/de18KxMGlZcEpAq\nb4r4HBXIRwp5ZpPcAkgZsAPVw29yOmaDNfxWPfNlZ+KVSGD8SHy49M/NWI+o\nhmaulRg0/Wvx/Uo5NkQSkE6B7RPilFoMRig8nuBhAYntIpPs747oYQKAjKiD\nOHK/Bx/JD0awBu25tzhW1sw5RL/pzymzwLhlPDFfEKSIfkqsTMrDp22UxNZ2\n99e5jHr1uwuNspNtADcwnGvjbsAOmcwIYVRq/s82O0X9+yGyruJ2kxOmK/14\ni/2ocH6qCSfH6G0+rQMROWpW5ZBJlnX5ew5+KfEA8WGHmVWxf0sI/BEzmlf8\nJPTF78lUMrS93/qDyDN/8goutY6xeNgtqvI7I9hwBDwHNpCMH4w3WyCQPcJd\nVPgWpYuT7vRBlaoJ+gLIbRu0t8dtl5Ablnquk137V+xFZRxO6c9r+gANHTkK\nvl02V4RCYBYNKTj54PgDlUfmDn9/FrM+f72+h4Eb7gqzdgCLHzlsvRWhZIbX\nZ6GVXICHCewDp6pAUV/PDHq6odQpwI7qX2Qfqsg/ZFXphXEXk1Z9zLecKx9Y\nYV9g0PHiN71VEkpuNsBFWzBTuR1VzEQX0MYEvO4QgMWuXGd3n0g50fPLeLvY\nFO/5\r\n=SFNb\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQCWqoFtcjWBrbpKulZgiIWKHmKGrbRkXNrnlMHKQccKHgIhAI2GE+EjR5A0u+mfk5Iltq+cTofNHsxZiHrgNocWo4RA"
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:05 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:afaa6a7d8c943fbadf4dd20ce6baeefcc63e32341afa8ee3aee42a77817604fd

Other collected versions

1.1.72 Mar1.1.62 Mar1.1.52 Mar1.1.42 Mar1.1.32 Mar1.1.22 MarView all collected versions →