mirror of
https://github.com/house-of-vanity/desubot.git
synced 2025-08-21 15:27:14 +00:00
Merge pull request #13 from house-of-vanity/libs-bump
Update telegram-bot for a new UpdateKind
This commit is contained in:
@@ -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 }
|
||||||
|
@@ -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(),
|
||||||
|
34
src/main.rs
34
src/main.rs
@@ -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(())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user