reverted previous changes. dependency upgrade
This commit is contained in:
parent
e866171ea7
commit
702743c108
623
Cargo.lock
generated
623
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
20
Cargo.toml
20
Cargo.toml
@ -1,15 +1,14 @@
|
||||
[package]
|
||||
name = "reminder_rs"
|
||||
version = "1.4.0"
|
||||
version = "1.4.0-alpha"
|
||||
authors = ["jellywx <judesouthworth@pm.me>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
dotenv = "0.15"
|
||||
chrono-english = "0.1.4"
|
||||
tokio = "0.2"
|
||||
reqwest = { version = "0.10", features = ["rustls-tls"] }
|
||||
sqlx = { version = "0.4", default-features = false, features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "chrono"] }
|
||||
# chrono-english = "0.1.4"
|
||||
tokio = { version = "1.0", features = ["process"] }
|
||||
reqwest = { version = "0.11", features = ["rustls-tls"] }
|
||||
regex = "1.4"
|
||||
log = "0.4"
|
||||
env_logger = "0.8"
|
||||
@ -24,10 +23,15 @@ rand = "0.7"
|
||||
Inflector = "0.11"
|
||||
levenshtein = "1.0"
|
||||
|
||||
[dependencies.serenity]
|
||||
version = "0.10.2"
|
||||
[dependencies.sqlx]
|
||||
git = "https://github.com/ant32/sqlx"
|
||||
default-features = false
|
||||
features = ["builder", "client", "framework", "cache", "gateway", "http", "model", "utils", "collector", "default_tokio_0_2"]
|
||||
features = ["runtime-tokio-rustls", "macros", "mysql", "bigdecimal", "chrono"]
|
||||
|
||||
[dependencies.serenity]
|
||||
version = "0.10"
|
||||
default-features = false
|
||||
features = ["builder", "client", "framework", "cache", "gateway", "http", "model", "utils", "collector", "rustls_backend"]
|
||||
|
||||
[dependencies.regex_command_attr]
|
||||
path = "./regex_command_attr"
|
||||
|
@ -16,8 +16,9 @@ use serenity::{
|
||||
use crate::{
|
||||
check_subscription_on_message, command_help,
|
||||
consts::{
|
||||
CHARACTERS, DAY, HOUR, LOCAL_TIMEZONE, MAX_TIME, MINUTE, MIN_INTERVAL, REGEX_CHANNEL,
|
||||
REGEX_CHANNEL_USER, REGEX_CONTENT_SUBSTITUTION, REGEX_REMIND_COMMAND, THEME_COLOR,
|
||||
CHARACTERS, DAY, HOUR, LOCAL_TIMEZONE, MAX_TIME, MINUTE, MIN_INTERVAL, PYTHON_LOCATION,
|
||||
REGEX_CHANNEL, REGEX_CHANNEL_USER, REGEX_CONTENT_SUBSTITUTION, REGEX_REMIND_COMMAND,
|
||||
THEME_COLOR,
|
||||
},
|
||||
framework::SendIterator,
|
||||
get_ctx_data,
|
||||
@ -25,7 +26,7 @@ use crate::{
|
||||
time_parser::TimeParser,
|
||||
};
|
||||
|
||||
use chrono::{offset::TimeZone, NaiveDateTime, Utc};
|
||||
use chrono::{offset::TimeZone, NaiveDateTime};
|
||||
|
||||
use rand::{rngs::OsRng, seq::IteratorRandom};
|
||||
|
||||
@ -44,10 +45,10 @@ use std::{
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use chrono_english::{parse_date_string, Dialect};
|
||||
use regex::{Captures, RegexBuilder};
|
||||
use serenity::cache::Cache;
|
||||
use serenity::model::guild::Guild;
|
||||
use tokio::process::Command;
|
||||
|
||||
fn shorthand_displacement(seconds: u64) -> String {
|
||||
let (days, seconds) = seconds.div_rem(&DAY);
|
||||
@ -1232,15 +1233,26 @@ async fn natural(ctx: &Context, msg: &Message, args: String) {
|
||||
let (time_crop_opt, msg_crop_opt) = (args_iter.next(), args_iter.next().map(|m| m.trim()));
|
||||
|
||||
if let (Some(time_crop), Some(msg_crop)) = (time_crop_opt, msg_crop_opt) {
|
||||
let res = parse_date_string(
|
||||
time_crop,
|
||||
Utc::now().with_timezone(&user_data.timezone()),
|
||||
Dialect::Uk,
|
||||
);
|
||||
|
||||
if let Ok(datetime) = res {
|
||||
let timestamp = datetime.timestamp();
|
||||
let python_call = Command::new(&*PYTHON_LOCATION)
|
||||
.arg("-c")
|
||||
.arg(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/dp.py")))
|
||||
.arg(time_crop)
|
||||
.arg(&user_data.timezone)
|
||||
.arg(&*LOCAL_TIMEZONE)
|
||||
.output()
|
||||
.await;
|
||||
|
||||
if let Some(timestamp) = python_call
|
||||
.ok()
|
||||
.map(|inner| {
|
||||
if inner.status.success() {
|
||||
Some(from_utf8(&*inner.stdout).unwrap().parse::<i64>().unwrap())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.flatten()
|
||||
{
|
||||
let mut location_ids = vec![ReminderScope::Channel(msg.channel_id.as_u64().to_owned())];
|
||||
let mut content = msg_crop;
|
||||
let mut interval = None;
|
||||
@ -1274,7 +1286,28 @@ async fn natural(ctx: &Context, msg: &Message, args: String) {
|
||||
|
||||
let interval_str = captures.name("interval").unwrap().as_str();
|
||||
|
||||
// todo
|
||||
let python_call = Command::new(&*PYTHON_LOCATION)
|
||||
.arg("-c")
|
||||
.arg(include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/dp.py")))
|
||||
.arg(&format!("1 {}", interval_str))
|
||||
.arg(&*LOCAL_TIMEZONE)
|
||||
.arg(&*LOCAL_TIMEZONE)
|
||||
.output()
|
||||
.await;
|
||||
|
||||
interval = python_call
|
||||
.ok()
|
||||
.map(|inner| {
|
||||
if inner.status.success() {
|
||||
Some(
|
||||
from_utf8(&*inner.stdout).unwrap().parse::<i64>().unwrap()
|
||||
- since_epoch.as_secs() as i64,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.flatten();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,4 +92,7 @@ lazy_static! {
|
||||
THEME_COLOR_FALLBACK,
|
||||
|inner| u32::from_str_radix(&inner, 16).unwrap_or(THEME_COLOR_FALLBACK)
|
||||
);
|
||||
|
||||
pub static ref PYTHON_LOCATION: String =
|
||||
env::var("PYTHON_LOCATION").unwrap_or_else(|_| "venv/bin/python3".to_string());
|
||||
}
|
||||
|
@ -399,6 +399,8 @@ impl Framework for RegexFramework {
|
||||
let member = guild.member(&ctx, &msg.author).await.unwrap();
|
||||
|
||||
if command.check_permissions(&ctx, &guild, &member).await {
|
||||
dbg!(command.name);
|
||||
|
||||
(command.func)(&ctx, &msg, args).await;
|
||||
} else if command.required_perms == PermissionLevel::Restricted
|
||||
{
|
||||
@ -474,6 +476,8 @@ impl Framework for RegexFramework {
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
|
||||
dbg!(command.name);
|
||||
|
||||
(command.func)(&ctx, &msg, args).await;
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +239,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/assets/",
|
||||
env!("STRINGS_FILE")
|
||||
)))?;
|
||||
)))
|
||||
.unwrap();
|
||||
|
||||
let mut data = client.data.write().await;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user