aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--src/agenda.rs2
-rw-r--r--src/discord.rs5
-rw-r--r--src/reminder.rs2
-rw-r--r--src/slack.rs5
5 files changed, 9 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 252b685..cd225e0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,4 +24,4 @@ features = [ "derive" ]
[dependencies.tokio]
version = "0.3"
-features = [ "macros", "rt", "rt-multi-thread", "sync" ]
+features = [ "macros", "rt", "rt-multi-thread", "sync", "time" ]
diff --git a/src/agenda.rs b/src/agenda.rs
index ce271cc..e27a4ca 100644
--- a/src/agenda.rs
+++ b/src/agenda.rs
@@ -95,7 +95,7 @@ where
}
}
-fn read_agenda() -> Agenda {
+pub fn read_agenda() -> Agenda {
match fs::read_to_string("agenda.json") {
Ok(s) => serde_json::from_str(&s).expect("Error parsing agenda.json"),
Err(_) => Agenda { points: Vec::new() },
diff --git a/src/discord.rs b/src/discord.rs
index 40c30ac..6ee42b7 100644
--- a/src/discord.rs
+++ b/src/discord.rs
@@ -169,8 +169,9 @@ async fn handle_reminders(
channel: Option<ChannelId>,
) {
if let Some(channel) = channel {
- while let Some(reminder) = reminder.recv().await {
- match reminder {
+ while reminder.changed().await.is_ok() {
+ let reminder = reminder.borrow();
+ match *reminder {
ReminderType::OneHour => {
client
.lock()
diff --git a/src/reminder.rs b/src/reminder.rs
index 2dc6eb0..fd05351 100644
--- a/src/reminder.rs
+++ b/src/reminder.rs
@@ -43,7 +43,7 @@ pub async fn handle(sender: watch::Sender<ReminderType>) {
match reminder.reminder_type {
ReminderType::OneHour => {
if in_remind_zone(now, next) && !in_remind_zone(reminder.last_fire, next) {
- sender.broadcast(ReminderType::OneHour).unwrap();
+ sender.send(ReminderType::OneHour).unwrap();
reminder.last_fire = now;
}
}
diff --git a/src/slack.rs b/src/slack.rs
index 0b02fac..170aa25 100644
--- a/src/slack.rs
+++ b/src/slack.rs
@@ -234,8 +234,9 @@ async fn handle_reminders(
channel: Option<String>,
) {
if let Some(channel) = channel {
- while let Some(reminder) = reminder.recv().await {
- match reminder {
+ while reminder.changed().await.is_ok() {
+ let reminder = reminder.borrow();
+ match *reminder {
ReminderType::OneHour => {
sender.send_typing(&channel).unwrap();
sender