UNPKG

html-telegram-bot-api

Version:
30 lines (22 loc) 640 B
const fs = require('fs') const program = require('commander') const Parser = require('./Parser') const TelegramBot = require('./TelegramBot') const pkg = require('../package.json') program .version(pkg.version) .arguments('<path/to/html/file>') .action(start) .parse(process.argv) if (program.args.length === 0) { console.error('filename is required') process.exit(1) } function start (filename) { const html = fs.readFileSync(filename).toString() const parser = new Parser(html) const { token, commands } = parser.parseHTML() const bot = new TelegramBot(token) bot.addCommands(commands) bot.startPolling() }