I
I
Ivan2019-06-22 11:59:57
Node.js
Ivan, 2019-06-22 11:59:57

I create my own bot for tg, but even the example from the github repository does not work?

I don't understand what I'm doing wrong.
I do it according to the article from Habr , created a bot in tg, got a token, copied the code from the telegraph repository, created index.js, initialized npm, added the telegraph itself to the folder, inserted my token, called it in the console node index.jsand got this:

const bot = new Telegraf(process.env.ЗДЕСЬ_БЫЛ_МОЙ_ТОКЕН)
                                 ^^^

SyntaxError: missing ) after argument list
    at Module._compile (internal/modules/cjs/loader.js:718:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11

bot code:
const Telegraf = require('telegraf')

const bot = new Telegraf(process.env.BOT_TOKEN)
bot.start((ctx) => ctx.reply('Welcome!'))
bot.help((ctx) => ctx.reply('Send me a sticker'))
bot.on('sticker', (ctx) => ctx.reply(''))
bot.hears('hi', (ctx) => ctx.reply('Hey there'))
bot.launch()

what am I doing wrong? what am i missing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2019-06-22
@BenderIsGreat34

(process.env.HERE_WAS_MY_TOKEN)
in the sense that it was written process.env."WOW_SUPER_TOKEN_3453454"?
values ​​are not added to process.env
https://www.npmjs.com/package/dotenv

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question