Compare commits
1 Commits
master
...
feature/te
| Author | SHA1 | Date | |
|---|---|---|---|
| 4cc17a27de |
19
Cargo.toml
19
Cargo.toml
@ -2,24 +2,29 @@
|
||||
name = "altherego"
|
||||
version = "0.9.9"
|
||||
authors = ["Aleksandr Trushkin <atrushkin@outlook.com>"]
|
||||
edition = "2018"
|
||||
edition = "2024"
|
||||
default-run = "altherego"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
teloxide = { version = "0.12.2", features = ["macros", "auto-send"] }
|
||||
tokio = {version = "1.8", features = ["full"]}
|
||||
tokio = { version = "1.8", features = ["full"] }
|
||||
uuid = { version = "0.8.1", features = ["v4"] }
|
||||
log = "0.4"
|
||||
env_logger = "0.8.1"
|
||||
envconfig = "0.9.1"
|
||||
serde = "1.0.137"
|
||||
serde = "1.0.219"
|
||||
reqwest = { version = "0.11.10", features = ["tokio-native-tls"] }
|
||||
serde_json = "1.0.81"
|
||||
sqlx = { version = "0.5.13", features = ["sqlite", "runtime-tokio-native-tls", "chrono", "migrate"] }
|
||||
chrono = "0.4.19"
|
||||
anyhow = "1.0.57"
|
||||
serde_json = "1.0.140"
|
||||
sqlx = { version = "0.8.3", features = [
|
||||
"sqlite",
|
||||
"runtime-tokio-native-tls",
|
||||
"chrono",
|
||||
"migrate",
|
||||
] }
|
||||
chrono = "0.4.40"
|
||||
anyhow = "1.0.97"
|
||||
async-trait = "0.1.53"
|
||||
tokio-stream = "0.1.8"
|
||||
rand = "0.8.5"
|
||||
|
||||
36
src/http.rs
Normal file
36
src/http.rs
Normal file
@ -0,0 +1,36 @@
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
use rocket::http::CookieJar;
|
||||
use rocket::serde::{json::Json, Deserialize};
|
||||
use rocket::State;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(crate = "rocker::serde")]
|
||||
struct NotifyBody<'r> {
|
||||
pub message: &'r str,
|
||||
}
|
||||
|
||||
struct BotContainer {
|
||||
bot: Arc<teloxide::Bot>,
|
||||
}
|
||||
|
||||
#[post("/notify", format = "json")]
|
||||
async fn handle_notifications(
|
||||
cookies: &CookieJar<'_>,
|
||||
body: Json<NotifyBody<'_>>,
|
||||
bot: &State<BotContainer>,
|
||||
) -> &'static str {
|
||||
"oh well"
|
||||
}
|
||||
|
||||
async fn launch(bot: Arc<teloxide::Bot>) -> Result<(), rocket::Error> {
|
||||
rocket::build()
|
||||
.manage(BotContainer { bot })
|
||||
.mount("/", routes![handle_notifications])
|
||||
.launch()
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
#![allow(unused)]
|
||||
|
||||
mod climate;
|
||||
mod http;
|
||||
mod repo;
|
||||
mod utils;
|
||||
|
||||
@ -9,7 +10,7 @@ use climate::SelfTemperature;
|
||||
use envconfig::Envconfig;
|
||||
use log::{debug, info, warn};
|
||||
use teloxide::{
|
||||
dispatching::{update_listeners::AsUpdateStream, UpdateFilterExt},
|
||||
dispatching::{UpdateFilterExt, update_listeners::AsUpdateStream},
|
||||
dptree::di::Injectable,
|
||||
filter_command,
|
||||
payloads::SendMessage,
|
||||
|
||||
@ -3,10 +3,10 @@ use std::str::FromStr;
|
||||
use anyhow::Result;
|
||||
use log::debug;
|
||||
use sqlx::{
|
||||
Executor, Pool, Sqlite,
|
||||
sqlite::{
|
||||
SqliteConnectOptions, SqliteError, SqliteJournalMode, SqlitePoolOptions, SqliteSynchronous,
|
||||
},
|
||||
Executor, Pool, Sqlite,
|
||||
};
|
||||
use teloxide::types::User;
|
||||
|
||||
@ -50,7 +50,6 @@ impl SqliteRepo {
|
||||
|
||||
let pool = SqlitePoolOptions::new()
|
||||
.max_connections(config.max_conns)
|
||||
.connect_timeout(config.timeout)
|
||||
.connect_with(opts)
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user