Update telegram-bot for a new UPDATEKU

This commit is contained in:
AB
2021-08-20 20:38:13 +03:00
parent ac2be9929a
commit 47c68ee432
3 changed files with 33 additions and 13 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "desubot"
version = "0.5.5"
version = "0.5.6"
authors = ["AB <ab@hexor.ru>"]
edition = "2018"
@ -12,7 +12,8 @@ tokio = { version = "0.2", features = ["full"]}
tracing = "0.1.9"
tracing-futures = "0.2"
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"
hyper = "0.13"
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?;
Here {
data: "".to_string(),

View File

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