Merge pull request #13 from house-of-vanity/libs-bump

Update telegram-bot for a new UpdateKind
This commit is contained in:
House of Vanity
2021-08-20 12:24:53 -07:00
committed by GitHub
3 changed files with 33 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "desubot" name = "desubot"
version = "0.5.5" version = "0.5.7"
authors = ["AB <ab@hexor.ru>"] authors = ["AB <ab@hexor.ru>"]
edition = "2018" edition = "2018"
@@ -12,7 +12,8 @@ tokio = { version = "0.2", features = ["full"]}
tracing = "0.1.9" tracing = "0.1.9"
tracing-futures = "0.2" tracing-futures = "0.2"
multipart = { version = "0.16", default-features = false, features = ["client"] } multipart = { version = "0.16", default-features = false, features = ["client"] }
telegram-bot = "0.8.0" #telegram-bot = "0.8.0"
telegram-bot = { git = "https://github.com/ayrat555/telegram-bot", branch = "ayrat555/api-fixes-10" }
silicon = "0.4.0" silicon = "0.4.0"
hyper = "0.13" hyper = "0.13"
hyper-tls = { version = "0.4", optional = true } hyper-tls = { version = "0.4", optional = true }

View File

@@ -53,7 +53,12 @@ pub async fn handler(
} }
} }
} }
s if s.contains("/here") || s.contains("@here") || s.contains("/хере") || s.contains("@хере") || s.contains("\"хере") => { s if s.contains("/here")
|| s.contains("@here")
|| s.contains("/хере")
|| s.contains("@хере")
|| s.contains("\"хере") =>
{
db::add_sentence(&message, mystem).await?; db::add_sentence(&message, mystem).await?;
Here { Here {
data: "".to_string(), data: "".to_string(),

View File

@@ -1,5 +1,6 @@
#![allow(unreachable_code)] #![allow(unreachable_code)]
use std::{env, process}; use std::{env, process};
use tokio::time::{delay_for, Duration};
use futures::StreamExt; use futures::StreamExt;
use telegram_bot::*; use telegram_bot::*;
@@ -47,18 +48,31 @@ async fn main() -> Result<(), errors::Error> {
); );
loop { loop {
while let Some(update) = stream.next().await { while let Some(update) = stream.next().await {
let update = update?; match update {
if let UpdateKind::Message(message) = update.kind { Ok(u) => {
db::add_conf(message.clone()).await?; if let UpdateKind::Message(message) = u.kind {
db::add_user(message.clone()).await?; db::add_conf(message.clone()).await?;
match handlers::handler(api.clone(), message, token.clone(), &mut mystem, me.clone()) db::add_user(message.clone()).await?;
.await match handlers::handler(
{ api.clone(),
Ok(_) => {} message,
Err(e) => warn!("An error occurred handling command. {:?}", e), token.clone(),
&mut mystem,
me.clone(),
)
.await
{
Ok(_) => {}
Err(e) => warn!("An error occurred handling command. {:?}", e),
}
}
} }
} Err(e) => {
warn!("Telegram API Error: {:?}", e);
}
};
} }
delay_for(Duration::from_secs(2)).await;
} }
Ok(()) Ok(())
} }