commit 79cac04cf1ea1c2cae45967e37ff98a85d8c40cc
Author: Daniel Pérez <steew@psi.my.domain>
Date: Fri Jan 09 18:48:04 2026 +0000
diff --git a/Cargo.toml b/Cargo.toml
index 966af60..de9d868 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -86 +86 @@ env = "1.0.1"
futures-util = "0.3.31"
irc = "1.1.0"
rust-ini = "0.21.3"
-serenity = "0.12.5"
+serenity = { version = "0.12.5", features = ["cache"]}
sha1 = "0.10.6"
tokio = { version = "1.49.0", features = ["rt-multi-thread"] }
diff --git a/src/main.rs b/src/main.rs
index 0e04c27..4954596 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -76 +77 @@ use ini::Ini;
use irc::client::data::Config;
use irc::proto::Command;
use serenity::all::ChannelId;
+use serenity::all::Settings;
use serenity::all::Webhook;
use serenity::prelude::*;
use tokio::spawn;
@@ -349 +3513 @@ async fn main() {
+
+ let mut cache_settings = Settings::default();
+ cache_settings.max_messages = 10_000;
- let intents = GatewayIntents::GUILD_MESSAGES | GatewayIntents::MESSAGE_CONTENT;
+ let intents = GatewayIntents::GUILD_MESSAGES | GatewayIntents::MESSAGE_CONTENT | GatewayIntents::GUILDS | GatewayIntents::GUILD_MEMBERS;
+ .cache_settings(cache_settings)
@@ -519 +5611 @@ async fn main() {
-
- let avatars: HashMap<String, String> = HashMap::new();
+ let avatars: HashMap<String, String> = HashMap::new();
+
+ // avatar url initialization
+
@@ -946 +1017 @@ async fn main() {
+
diff --git a/src/relay.rs b/src/relay.rs
index f779a65..fd3de28 100644
--- a/src/relay.rs
+++ b/src/relay.rs
@@ -1657 +16525 @@ pub async fn relay_consumer(
+ // let guilds = http.get_guilds(None, None).await.unwrap();
+ // for guild in guilds {
+ // let members = http.get_guild_members(guild.id, None, None).await.unwrap();
+ // for member in members {
+ // println!("Member: {:?}", member.nick);
+ // let mut name = member.user.name.clone();
+ // if let Some(nick) = member.nick.clone() {
+ // name = nick;
+ // }
+ // if pending.author.eq_ignore_ascii_case(&name) {
+ // println!("Found match: {}", name);
+ // avatar_url = member.avatar_url;
+ // println!("Avatar URL: {:?}", avatar_url);
+ // break;
+ // }
+ // }
+ // }
+
diff --git a/src/relay_discord.rs b/src/relay_discord.rs
index 00ea812..cb2745d 100644
--- a/src/relay_discord.rs
+++ b/src/relay_discord.rs
@@ -16 +17 @@
use std::hash::Hash;
use serenity::all::Message;
+use serenity::all::MessageUpdateEvent;
use serenity::all::Ready;
use serenity::async_trait;
use serenity::prelude::*;
@@ -426 +4349 @@ impl EventHandler for Handler {
+ async fn message_update(&self,
+ ctx: Context,
+ old_if_available: Option<Message>,
+ new_if_available: Option<Message>,
+ event: MessageUpdateEvent)
+ {
+ // if the original or new message is not available, it doesn't make sense to store it, as the IRC
+ // side would have no context of the edit.
+ if let None = old_if_available { return };
+ if let None = new_if_available { return };
+
+ let old = old_if_available.unwrap();
+ let new = new_if_available.unwrap();
+
+ // open the shared lock as write
+ let data = ctx.data.read().await;
+ let buffer_lock = data.get::<MessageBuffer>().unwrap().clone();
+
+ if let Some(_) = old.webhook_id {
+ println!("Discarding webhook edit.");
+ return;
+ };
+
+ {
+ let mut relay_buffer = buffer_lock.write().await;
+ // create a new message with the received discord message contents
+ let mut new_message = RelayMessage::default();
+ new_message.direction = RelayDirection::DIS2IRC(new.channel_id);
+ new_message.author = new.author.name;
+
+ let edit_message = format!("edited: \"{}\"\r\n\t↪ {}", old.content, new.content);
+ new_message.contents = edit_message;
+
+ // push the pending message to the relay buffer
+ relay_buffer.pending_relay_messages.push_back(new_message);
+ }
+ {
+ let notify = data.get::<RelayNotify>().unwrap().clone();
+ notify.notify.notify_one();
+ }
+
+ }
+