-
Notifications
You must be signed in to change notification settings - Fork 12
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
[enhancement] Add a reactive $bot.listen method that automatically reads messages #10
Comments
@WildYorkies can you elaborate? |
For example, look at this section of a javascript bot library for telegram: https://github.com/mast/telegram-bot-api#retrieve-messages-sent-to-your-bot Perl 6 has a really nice abstraction for listening to messages that are emitted. Is that out of scope for this library? |
@WildYorkies I'm not familiar with that yet. Can you show how a user would use it if it was added? |
Good question! Using the JS library as an example, if someone passes an "updates" boolean to use Telegram;
var $bot = Telegram::Bot.new($token, :updates);
react {
whenever $bot -> $message {
when 'message' { say $message; }
when 'inline.query' { say $message; }
}
} Of course, I'm no expert on asynchrony. I'm just thinking about how Perl 6 might be able to mimmick the JS functionality described in what I linked above. Obviously, the actual API for this module could be different from the JS one, though. edit: See this function in the js lib for how they do it. They use the EventEmitter library, which is built in to Perl 6 by default :) |
@WildYorkies probably yes, but later. |
Would it be possible to add a
listen
method that just listens for updates with astart
block?So you could utilize P6's nice
react whenever
system instead of using callbacks and what-not?Or does the telegram API not allow for the constant connection?
The text was updated successfully, but these errors were encountered: