Closed PollyDrive closed 4 years ago
upgrading telegraf package fixed mine
based on PollyDrive/activecollab-telegram-bot package.json there is already the latest version of telegraf used (0.26.0 at the moment).
I am not sure what happened for this error to occur? For example what kind of button was pressed?
I don't get it from pressing buttons it's from start at init and when I upgraded telegraf it worked properly but today I wanted to reproduce it so I tested your example using npm and get the above error and when I upgrade telegraf using yarn it gets fixed
"@types/node@^10.1.2":
version "10.12.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67"
debug@^4.0.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
dependencies:
ms "^2.1.1"
ms@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
node-fetch@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5"
sandwich-stream@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/sandwich-stream/-/sandwich-stream-2.0.2.tgz#6d1feb6cf7e9fe9fadb41513459a72c2e84000fa"
telegraf-inline-menu@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/telegraf-inline-menu/-/telegraf-inline-menu-3.2.2.tgz#ae3d2be2003117d8cfdba910b61935f8197ce01e"
dependencies:
telegraf "^3.26.0"
telegraf@^3.26.0:
version "3.26.0"
resolved "https://registry.yarnpkg.com/telegraf/-/telegraf-3.26.0.tgz#6102280c7971431a8a8a96fe0502285cc1a223c9"
dependencies:
"@types/node" "^10.1.2"
debug "^4.0.1"
node-fetch "^2.2.0"
sandwich-stream "^2.0.1"
telegram-typings "^3.6.0"
telegram-typings@^3.6.0:
version "3.6.1"
resolved "https://registry.yarnpkg.com/telegram-typings/-/telegram-typings-3.6.1.tgz#1288d547f8694b61f1c01c2993e295f3114d9e25"
I had no luck with recreating it.
I simply generated a new project, installed telegraf-inline-menu and ran a copy of example.js
.
I also used older versions of telegraf and older versions of telegraf-inline-menu without any errors.
I doubt it is a startup error as on the startup of telegraf-inline-menu no telegraf is involved. I assume there was a message that was not yet handled before the start so it happened while handling the first updates (after bot.startPolling()
was called).
Any ideas how to recreate this error?
well, I've tested it on other machines, it worked fine so I Thought it was related to npm and a reinstall fixed it
I just close this as it does not seem to be reproducible with up to date Telegraf versions.
I still have encountered this problem
package.json
"telegraf": "^3.35.0",
"telegraf-inline-menu": "^4.0.0",
package-lock.json
"telegraf": {
"version": "3.35.0",
...
}
...
"telegraf-inline-menu": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/telegraf-inline-menu/-/telegraf-inline-menu-4.0.0.tgz",
"integrity": "sha512-1tEL9+xfq9/HA8pD0XebfQeqKg6+aqqtlBck/GGXxK/BrA1L15Ou8z7mXnAI9lVdrFWuMVguG2sZpiwpAviFYw=="
},
In my setup, a typescript project with nestjs + other middlewares it still breaks with this very same error. However, executing the example.js or the example.ts alone works... 🤔
I have multiple bots running with v4.0.0 without any problems. Various telegraf versions worked for me. I have no idea how to reproduce it currently… 🤔
@EdJoPaTo I'm really sorry that I had you re-open this issue: I think I found out the problem! I had multiple instances of Telegraf (with the same version 3.35.0).
I was contributing to https://github.com/bukhalo/nestjs-telegraf and so I installed it in my project via npm i ../nestjs-telegraf
instead of having it packed with npm pack
.
So I had 2 copies of the Telegraf library being called from 2 different node_modules
folders, thus invalidating the bot context since the menu were registered to a different instance than the other middlewares I was using. I notice this path difference quite late when looking in the debugger inspector.
I'm glad I found it finally out, but I feel also a bit dumb.
Don’t feel dumb :) It took time so it’s nothing obvious. Also something like that occurred to others before without any explanation why. Maybe it helps others to prevent mistakes like that in the future. Thanks for sharing! :)