natural command stuff

This commit is contained in:
jude 2020-09-26 22:23:41 +01:00
parent f13853d445
commit 8a0588b04e
3 changed files with 21 additions and 7 deletions

6
.idea/reminder-rs.iml generated
View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
@ -7,5 +12,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 3.8 (reminder-rs) interpreter library" level="application" />
</component>
</module>

2
dp.py
View File

@ -10,4 +10,4 @@ dt = dateparser.parse(sys.argv[1], settings={
'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))

View File

@ -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 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());
@ -744,13 +744,15 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
.output()
.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() {
from_utf8(&*inner.stdout).unwrap().parse::<f64>().unwrap().round().to_i64()
Some(from_utf8(&*inner.stdout).unwrap().parse::<i64>().unwrap())
}
else {
None
}).flatten() {
}}).flatten() {
let mut location_ids = vec![ReminderScope::Channel(msg.channel_id.as_u64().to_owned())];
let mut content = msg_crop;
@ -796,15 +798,21 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
if res.is_ok() {
issue_count += 1;
}
else {
println!("{:?}", res);
}
}
let _ = msg.channel_id.say(&ctx, format!("successfully set {} reminders", issue_count)).await;
}
// something not right with the time parse
else {
println!("ewifjewiof");
}
}
else {
println!("aaaaaaaaaaaaaaaaaaa");
}
Ok(())
}