Update heroku and ngrok examples

This commit is contained in:
Waffle 2021-07-06 15:10:22 +03:00
parent 30644ab162
commit 183486a044
2 changed files with 6 additions and 4 deletions

View file

@ -8,7 +8,7 @@ use tokio::sync::mpsc;
use tokio_stream::wrappers::UnboundedReceiverStream;
use warp::Filter;
use reqwest::StatusCode;
use reqwest::{StatusCode, Url};
#[tokio::main]
async fn main() {
@ -30,7 +30,7 @@ pub async fn webhook(bot: AutoSend<Bot>) -> impl update_listeners::UpdateListene
// Heroku host example .: "heroku-ping-pong-bot.herokuapp.com"
let host = env::var("HOST").expect("have HOST env variable");
let path = format!("bot{}", teloxide_token);
let url = format!("https://{}/{}", host, path);
let url = Url::parse(&format!("https://{}/{}", host, path)).unwrap();
bot.set_webhook(url).await.expect("Cannot setup a webhook");

View file

@ -8,7 +8,7 @@ use tokio::sync::mpsc;
use tokio_stream::wrappers::UnboundedReceiverStream;
use warp::Filter;
use reqwest::StatusCode;
use reqwest::{StatusCode, Url};
#[tokio::main]
async fn main() {
@ -21,9 +21,11 @@ async fn handle_rejection(error: warp::Rejection) -> Result<impl warp::Reply, In
}
pub async fn webhook(bot: AutoSend<Bot>) -> impl update_listeners::UpdateListener<Infallible> {
let url = Url::parse("Your HTTPS ngrok URL here. Get it by `ngrok http 80`").unwrap();
// You might want to specify a self-signed certificate via .certificate
// method on SetWebhook.
bot.set_webhook("Your HTTPS ngrok URL here. Get it by `ngrok http 80`")
bot.set_webhook(url)
.await
.expect("Cannot setup a webhook");