test build

This commit is contained in:
Aleksandr Trushkin
2025-03-28 21:06:30 +03:00
parent 6186436ea8
commit 4cc17a27de
4 changed files with 51 additions and 10 deletions

View File

@ -2,24 +2,29 @@
name = "altherego" name = "altherego"
version = "0.9.9" version = "0.9.9"
authors = ["Aleksandr Trushkin <atrushkin@outlook.com>"] authors = ["Aleksandr Trushkin <atrushkin@outlook.com>"]
edition = "2018" edition = "2024"
default-run = "altherego" default-run = "altherego"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
teloxide = { version = "0.12.2", features = ["macros", "auto-send"] } 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"] } uuid = { version = "0.8.1", features = ["v4"] }
log = "0.4" log = "0.4"
env_logger = "0.8.1" env_logger = "0.8.1"
envconfig = "0.9.1" envconfig = "0.9.1"
serde = "1.0.137" serde = "1.0.219"
reqwest = { version = "0.11.10", features = ["tokio-native-tls"] } reqwest = { version = "0.11.10", features = ["tokio-native-tls"] }
serde_json = "1.0.81" serde_json = "1.0.140"
sqlx = { version = "0.5.13", features = ["sqlite", "runtime-tokio-native-tls", "chrono", "migrate"] } sqlx = { version = "0.8.3", features = [
chrono = "0.4.19" "sqlite",
anyhow = "1.0.57" "runtime-tokio-native-tls",
"chrono",
"migrate",
] }
chrono = "0.4.40"
anyhow = "1.0.97"
async-trait = "0.1.53" async-trait = "0.1.53"
tokio-stream = "0.1.8" tokio-stream = "0.1.8"
rand = "0.8.5" rand = "0.8.5"

36
src/http.rs Normal file
View 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(())
}

View File

@ -1,6 +1,7 @@
#![allow(unused)] #![allow(unused)]
mod climate; mod climate;
mod http;
mod repo; mod repo;
mod utils; mod utils;
@ -9,7 +10,7 @@ use climate::SelfTemperature;
use envconfig::Envconfig; use envconfig::Envconfig;
use log::{debug, info, warn}; use log::{debug, info, warn};
use teloxide::{ use teloxide::{
dispatching::{update_listeners::AsUpdateStream, UpdateFilterExt}, dispatching::{UpdateFilterExt, update_listeners::AsUpdateStream},
dptree::di::Injectable, dptree::di::Injectable,
filter_command, filter_command,
payloads::SendMessage, payloads::SendMessage,

View File

@ -3,10 +3,10 @@ use std::str::FromStr;
use anyhow::Result; use anyhow::Result;
use log::debug; use log::debug;
use sqlx::{ use sqlx::{
Executor, Pool, Sqlite,
sqlite::{ sqlite::{
SqliteConnectOptions, SqliteError, SqliteJournalMode, SqlitePoolOptions, SqliteSynchronous, SqliteConnectOptions, SqliteError, SqliteJournalMode, SqlitePoolOptions, SqliteSynchronous,
}, },
Executor, Pool, Sqlite,
}; };
use teloxide::types::User; use teloxide::types::User;
@ -50,7 +50,6 @@ impl SqliteRepo {
let pool = SqlitePoolOptions::new() let pool = SqlitePoolOptions::new()
.max_connections(config.max_conns) .max_connections(config.max_conns)
.connect_timeout(config.timeout)
.connect_with(opts) .connect_with(opts)
.await?; .await?;