summary refs log tree commit diff
path: root/src/system/bot
diff options
context:
space:
mode:
Diffstat (limited to 'src/system/bot')
-rw-r--r--src/system/bot/client.rs16
-rw-r--r--src/system/bot/gateway.rs2
-rw-r--r--src/system/bot/mod.rs8
3 files changed, 17 insertions, 9 deletions
diff --git a/src/system/bot/client.rs b/src/system/bot/client.rs
index 006ce8f..61d7515 100644
--- a/src/system/bot/client.rs
+++ b/src/system/bot/client.rs
@@ -23,18 +23,22 @@ impl Client {
         }
     }
 
-    pub async fn refetch_message(&self, message_id: MessageId, channel_id: ChannelId) {
+    pub async fn fetch_message(&self, message_id: MessageId, channel_id: ChannelId) -> FullMessage {
         let client = self.client.lock().await;
-        let bot_conf = self.bot_conf.read().await;
-        let message_channel = bot_conf.message_handler.as_ref().expect("No message handler");
 
-        let message = client
+        client
             .message(channel_id, message_id)
             .await
             .expect("Could not load message")
             .model()
             .await
-            .expect("Could not deserialize message");
+            .expect("Could not deserialize message")
+    }
+
+    pub async fn resend_message(&self, message_id: MessageId, channel_id: ChannelId) {
+        let bot_conf = self.bot_conf.read().await;
+        let message = self.fetch_message(message_id, channel_id).await;
+        let message_channel = bot_conf.message_handler.as_ref().expect("No message handler");
 
         let timestamp = if message.edited_timestamp.is_some() {
             message.edited_timestamp.unwrap()
@@ -43,7 +47,7 @@ impl Client {
         };
 
         message_channel
-            .send((timestamp, Message::Complete(message)))
+            .send((timestamp, Message::Complete(message, bot_conf.member_id)))
             .await;
     }
 
diff --git a/src/system/bot/gateway.rs b/src/system/bot/gateway.rs
index 5a45083..5a343d1 100644
--- a/src/system/bot/gateway.rs
+++ b/src/system/bot/gateway.rs
@@ -94,7 +94,7 @@ impl Gateway {
                             }
 
                             message_channel
-                                .send((message.timestamp, Message::Complete(message)))
+                                .send((message.timestamp, Message::Complete(message, bot_conf.member_id)))
                                 .await;
                         }
 
diff --git a/src/system/bot/mod.rs b/src/system/bot/mod.rs
index 3c4585f..2f38075 100644
--- a/src/system/bot/mod.rs
+++ b/src/system/bot/mod.rs
@@ -66,8 +66,12 @@ impl Bot {
         self.gateway.start_listening()
     }
 
-    pub async fn refetch_message(&self, message_id: MessageId, channel_id: ChannelId) {
-        self.client.refetch_message(message_id, channel_id).await;
+    pub async fn fetch_message(&self, message_id: MessageId, channel_id: ChannelId) -> TwiMessage {
+        self.client.fetch_message(message_id, channel_id).await
+    }
+
+    pub async fn resend_message(&self, message_id: MessageId, channel_id: ChannelId) {
+        self.client.resend_message(message_id, channel_id).await;
     }
 
     pub async fn delete_message(&self, channel_id: ChannelId, message_id: MessageId) -> Result<(), TwiError> {