Desiders / telers

An asynchronous framework for Telegram Bot API written in Rust
https://docs.rs/telers
36 stars 3 forks source link

Need ability to run bot in separate thread without subscribing to os signals #1

Closed amityagov closed 1 year ago

amityagov commented 1 year ago

Hello. I am trying to run bot alongside with axum server in one application. However, dispatcher creates subscription to os signals (ctrl+c, ctrl+break, etc) for handling appropriate signals. I wish i have abiility to run dispatcher in separate tokio thread with passing some kind of rust feature for sending signal to dispatcher.

Thanks

Desiders commented 1 year ago

Hi, thanks for the issue!

What do you think about using tokio::join and tokio::spawn for this purpose? Just spawn polling in another thread.

I created a simple example: https://github.com/Desiders/telers/blob/axum_polling_example/examples/axum_and_echo_bot/src/main.rs https://github.com/Desiders/telers/blob/dev-1.x/examples/axum_and_echo_bot/src/main.rs

Waiting for your opinion :)

amityagov commented 1 year ago

Hello, i think this will work, thanks!