natural command stuff
This commit is contained in:
parent
f13853d445
commit
8a0588b04e
@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="CPP_MODULE" version="4">
|
<module type="CPP_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="Python" name="Python facet">
|
||||||
|
<configuration sdkName="Python 3.8 (reminder-rs)" />
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
@ -7,5 +12,6 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Python 3.8 (reminder-rs) interpreter library" level="application" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
2
dp.py
2
dp.py
@ -10,4 +10,4 @@ dt = dateparser.parse(sys.argv[1], settings={
|
|||||||
'PREFER_DATES_FROM': 'future',
|
'PREFER_DATES_FROM': 'future',
|
||||||
})
|
})
|
||||||
|
|
||||||
print(dt.timestamp() if dt is not None else -1)
|
sys.stdout.write(str(int(dt.timestamp()) if dt is not None else -1))
|
||||||
|
@ -729,9 +729,9 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
|
|
||||||
let send_str = user_data.response(&pool, "natural/send").await;
|
let send_str = user_data.response(&pool, "natural/send").await;
|
||||||
let to_str = user_data.response(&pool, "natural/to").await;
|
let to_str = user_data.response(&pool, "natural/to").await;
|
||||||
let every_str = user_data.response(&pool, "natural/every").await;
|
// let every_str = user_data.response(&pool, "natural/every").await;
|
||||||
|
|
||||||
let mut args_iter = args.splitn(1, &send_str);
|
let mut args_iter = args.splitn(2, &send_str);
|
||||||
|
|
||||||
let (time_crop_opt, msg_crop_opt) = (args_iter.next(), args_iter.next());
|
let (time_crop_opt, msg_crop_opt) = (args_iter.next(), args_iter.next());
|
||||||
|
|
||||||
@ -744,13 +744,15 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
.output()
|
.output()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
if let Some(timestamp) = python_call.ok().map(|inner|
|
if let Some(timestamp) = python_call.ok().map(|inner| {
|
||||||
|
println!("{}", from_utf8(&*inner.stdout).unwrap());
|
||||||
|
|
||||||
if inner.status.success() {
|
if inner.status.success() {
|
||||||
from_utf8(&*inner.stdout).unwrap().parse::<f64>().unwrap().round().to_i64()
|
Some(from_utf8(&*inner.stdout).unwrap().parse::<i64>().unwrap())
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
None
|
None
|
||||||
}).flatten() {
|
}}).flatten() {
|
||||||
|
|
||||||
let mut location_ids = vec![ReminderScope::Channel(msg.channel_id.as_u64().to_owned())];
|
let mut location_ids = vec![ReminderScope::Channel(msg.channel_id.as_u64().to_owned())];
|
||||||
let mut content = msg_crop;
|
let mut content = msg_crop;
|
||||||
@ -796,15 +798,21 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|||||||
if res.is_ok() {
|
if res.is_ok() {
|
||||||
issue_count += 1;
|
issue_count += 1;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
println!("{:?}", res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = msg.channel_id.say(&ctx, format!("successfully set {} reminders", issue_count)).await;
|
let _ = msg.channel_id.say(&ctx, format!("successfully set {} reminders", issue_count)).await;
|
||||||
}
|
}
|
||||||
// something not right with the time parse
|
// something not right with the time parse
|
||||||
else {
|
else {
|
||||||
|
println!("ewifjewiof");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
println!("aaaaaaaaaaaaaaaaaaa");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user