bytesnake / telebot

Write Telegram bots in Rust with Tokio and Futures
Other
212 stars 33 forks source link

add a way to send unprompted messages #66

Closed TheBestJohn closed 5 years ago

TheBestJohn commented 5 years ago

It would be useful to be able to send a message without a command needing to be registered. If I have some form of hardware or a build running I'd like to be able to do something like bot.message(&saved_id, "Build is done").send()

I may just really be suffering from a lack of understanding of futures. Basically I want to be able to register a function into the bots execution queue from exterior functions.

bytesnake commented 5 years ago

If you want to issue a single telegram after something is done, curl will probably be simpler to use: https://gist.github.com/krustnic/536224308a49dd93623d90e1ac4d6df8

Otherwise your application can execute the future either with a spawn or by returning it from an arbitrary and_then call.

TheBestJohn commented 5 years ago

Ah I see, this crate is more for handling the reactionary user interaction part of a telegram bot. Other commands need not be set in futures. I guess my understanding of the core issue was off. Thank you for your comments :)

bytesnake commented 5 years ago

Yeah my point was that it is unnecessary to pull in 150+ dependencies just to send a single Telegram message, it makes only sense if you have more complex application or are already using tokio

TheBestJohn commented 5 years ago

Well I am wanting the ability to set up a "administration" sort of interface that this is perfect for. I want to subscribe to several different processes, events, reminders etc. Sending the needed media/messages once they come in can be handled by different threads or something I suppose.