Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Error: next(ctx) called with invalid context #18

Open
lgg opened this issue Dec 13, 2018 · 4 comments
Open

Error: next(ctx) called with invalid context #18

lgg opened this issue Dec 13, 2018 · 4 comments

Comments

@lgg
Copy link

lgg commented Dec 13, 2018

Tried:

npm install micro-bot
npm init bot smart-bot
yarn create bot smart-bot
micro-bot -t TOKEN index.js

Bot started but got error:

Output:

Failed to fetch updates. Waiting: 1s request to https://api.telegram.org/tokenhere/getUpdates?offset=340740293&limit=100&timeout=30 failed, reason: connect ETIMEDOUT 149.154.167.220:443
μ-bot: Unhandled error Error: next(ctx) called with invalid context
    at execute (D:\dev\temp\rtumireaprofkombot\node_modules\telegraf\composer.js:301:33)
    at D:\dev\temp\rtumireaprofkombot\node_modules\telegraf\composer.js:298:14
    at execute (C:\Users\Фёдор\AppData\Roaming\npm\node_modules\micro-bot\node_modules\telegraf\composer.js:313:13)
    at Promise.resolve.handler (C:\Users\Фёдор\AppData\Roaming\npm\node_modules\micro-bot\node_modules\telegraf\composer.js:313:49)
    at C:\Users\Фёдор\AppData\Roaming\npm\node_modules\micro-bot\node_modules\telegraf\composer.js:114:56
    at execute (C:\Users\Фёдор\AppData\Roaming\npm\node_modules\micro-bot\node_modules\telegraf\composer.js:313:13)
    at C:\Users\Фёдор\AppData\Roaming\npm\node_modules\micro-bot\node_modules\telegraf\composer.js:298:14
    at Telegraf.handleUpdate (C:\Users\Фёдор\AppData\Roaming\npm\node_modules\micro-bot\node_modules\telegraf\telegraf.js:155:29)
    at Promise.all.updates.map (C:\Users\Фёдор\AppData\Roaming\npm\node_modules\micro-bot\node_modules\telegraf\telegraf.js:140:65)
    at Array.map (<anonymous>)
@lgg
Copy link
Author

lgg commented Dec 13, 2018

index.js

const {Composer, log, session} = require('micro-bot')

const bot = new Composer()

bot.use(log())
bot.use(session())

bot.start(({reply}) => reply('Welcome message'))
bot.help(({reply}) => reply('Help message'))
bot.settings(({reply}) => reply('Bot settings'))

bot.command('date', ({reply}) => reply(`Server time: ${Date()}`))

module.exports = bot

package.json

{
  "name": "rtumireaprofkombot",
  "version": "0.0.0",
  "description": "RTU MIREA Profkom bot",
  "repository": {
    "url": "lgg/rtumireaprofkombot",
    "type": "git"
  },
  "main": "index.js",
  "scripts": {
    "dev": "supervisor -x micro-bot index.js",
    "start": "micro-bot",
    "now-start": "micro-bot -d ${NOW_URL}",
    "lint": "eslint .",
    "test": "npm run lint"
  },
  "engines": {
    "node": ">=8.5.0"
  },
  "author": "lgg",
  "license": "MIT",
  "dependencies": {
    "micro-bot": "^2.5.1"
  },
  "devDependencies": {
    "eslint": "^5.9.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-node": "^8.0.0",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-standard": "^4.0.0",
    "supervisor": "^0.12.0"
  }
}

@darshantejani007
Copy link

How did you solve this error? I'm also facing the same issue!

@lgg
Copy link
Author

lgg commented Nov 12, 2020

@darshantejani007 I didn't solve this issue. I used pure telegraf in new projects (empty repo) and for some reason it worked...

@amjadcp
Copy link

amjadcp commented May 29, 2022

I used telegraf to access telegram bot api and express for server creation :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants