-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for Telegram Bots 2.0 #102
Conversation
Nice, you were really quickly. 👏 👏 👏 Some test are needed. Maybe in some functions is almost impossible (the project doesn't have a mocked server) to test but others are. |
Sure, I'll add some tests when I get the time. |
Very good work!!!
Are you planning to pull the code? Thanks in advance! |
Hi @tjhorner , I've tried your pull-request, but receive the following error;
Which node-version are you using? |
Seems to work for me, @tim427. It also doesn't seem related to my pull request, but I'm on |
Doesn't it need to be modified in order to properly receive POSTs with Otherwise there's no way to really answer callback queries since the message is never received. Also, at least basic documentation of the methods added. |
@icdevin You are correct, if you'd like to add that go ahead, but this PR isn't really at the top of my priority list. Also bots can be admined in supergroups now. I don't think I'll actually be able to write any of the tests soon, so if someone wants to take over that would be nice... |
Sure. I'll write the tests. Seems to be a pretty popular request. I'll need some time to do the group stuff as I haven't actually used it before but shouldn't be too difficult, I imagine. Thanks for your work thus far, @tjhorner. What's the proper way to get my changes to this PR? I'd like to preserve your changes, of course. Should I make a PR to your branch? |
That could work. If you fork my repo and checkout the The responses are pretty straightforward too, just check for an |
Does anyone else get a lot of timeouts when running the normal tests? I find a majority of them taking over the default 2000 ms threshold for failure. When I upped it to 5000 ms, all passed with the exception of two sendVideo tests. I'd like to set the default timeout for tests to 10,000 ms to account for a wider variety of network latencies. This is what they're doing over in Python Telegram Bot as well. @yagop? |
Just depends on you network speed and how bad are the Telegram servers. Currently I got 964ms on sendVideo, if you want you can pass |
when will the merge happen? |
I'm gonna try to finish this up in the next couple days. Sorry guys, been on vacation 😄! |
@icdevin thanks, we wait for it |
- Adds support for callback_query-type messages - Adds a showAlert option to answerCallbackQuery to more-closely align with the real bot API - Adds tests for message editing functionality - Adds a global test timeout of 10s and adds done() calls to all tests for assurance
Further updates for Bots 2.0
Removes unnecessary done() calls in tests
@yagop: Removed the extraneous done() calls. |
I updated my Node to the latest one: node -p process.versions.v8 Im sure its because of ES6... but dont understant how to fix it. |
@zigzag-way Does this question have anything to do with this issue? If not, could you please open a new issue that's specific to your problem? |
I posted it here because I have the same problem as one of the guys posted here. |
And this problem is related with this Bot2.0 fork because it`s rewritten in ES6 |
@zigzag-way You could create an issue on the fork. |
* @param {String} caption New caption of the message | ||
* @param {Object} [options] Additional Telegram query options (provide either one of chat_id, message_id, or inline_message_id here) | ||
* @return {Promise} | ||
* @see https://core.telegram.org/bots/api#editmessagetext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add `all` option - add `kickChatMember`, `unbanChatMember`, `answerCallbackQuery` - add `editMessageText`, `editMessageCaption`, `editMessageReplyMarkup` related issue: yagop/node-telegram-bot-api#102
As it seems many people are having problems with this PR, I am going to make a new fork of the latest version of the library and try to implement it with as much compatibility as possible. I'll also add the listeners for callback requests and some of the functions I missed. I will most likely have time sometime this week. I've also used this library for inline keyboards with some hacky stuff and the |
When will the merge happen? |
For who needs a not ES6 version with bot 2.0, here there is what I use: https://github.com/Kaos1337/node-telegram-bot-api |
Merged and published 0.22.0. I'm really really sorry for not doing it before but I haven't too much time and has lost a bit of motivation. |
No worries @yagop! I've just been using my local version for my projects for now. |
@@ -110,6 +111,9 @@ class TelegramBot extends EventEmitter { | |||
} else if (chosenInlineResult) { | |||
debug('Process Update chosen_inline_result %j', chosenInlineResult); | |||
this.emit('chosen_inline_result', chosenInlineResult); | |||
} else if (callbackQuery) { | |||
debug('Process Update callback_query %j', callbackQuery); | |||
this.emit('callback_query', callbackQuery); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need mention in readme#Events
Telegram Bots 2.0!
I've added the new methods from the updated Bots API in Telegram. This includes all of the methods for kicking/banning users as well.
The APIs for kicking and unbanning chat members don't seem to work right now because it says the bots must be admins in the groups, but there's no way to make bots admins in groups quite yet. (unless I'm missing something...)
EDIT: It seems that the developers are aware that users cannot make bots admins and are fixing it. Personally, I think they're trying a slow rollout.
Methods added
kickChatMember
unbanChatMember
answerCallbackQuery
editMessageText
editMessageCaption
editMessageReplyMarkup