html-telegram-bot-api
Advanced tools
Comparing version 0.2.7 to 0.2.8
{ | ||
"name": "html-telegram-bot-api", | ||
"description": "Now you can write Telegram bots in HTML.", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"main": "src/index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -23,3 +23,3 @@ # html-telegram-bot-api | ||
```console | ||
$ html-telegram-bot [options] <path-to-html-file> | ||
$ html-telegram-bot [options] <path/to/html/file> | ||
``` | ||
@@ -30,3 +30,3 @@ | ||
```console | ||
$ html-telegram-bot-api [options] <path-to-html-file> | ||
$ html-telegram-bot-api [options] <path/to/html/file> | ||
``` | ||
@@ -69,2 +69,6 @@ | ||
## Related | ||
* [css-telegram-bot-api](https://github.com/Bannerets/css-telegram-bot-api) | ||
## CLI Options | ||
@@ -71,0 +75,0 @@ |
@@ -7,19 +7,24 @@ const fs = require('fs') | ||
let filename = '' | ||
program | ||
.version(pkg.version) | ||
.arguments('<path-to-html-file>') | ||
.action(arg => (filename = arg)) | ||
.arguments('<path/to/html/file>') | ||
.action(start) | ||
.parse(process.argv) | ||
const html = fs.readFileSync(filename).toString() | ||
if (program.args.length === 0) { | ||
console.error('filename is required') | ||
process.exit(1) | ||
} | ||
const parser = new Parser(html) | ||
function start (filename) { | ||
const html = fs.readFileSync(filename).toString() | ||
const { token, commands } = parser.parseHTML() | ||
const parser = new Parser(html) | ||
const bot = new TelegramBot(token) | ||
const { token, commands } = parser.parseHTML() | ||
bot.addCommands(commands) | ||
bot.startPolling() | ||
const bot = new TelegramBot(token) | ||
bot.addCommands(commands) | ||
bot.startPolling() | ||
} |
Sorry, the diff of this file is not supported yet
76
12498
14
195