From fedd8ce179d56ac6696fa68e446add1d7459fd2f Mon Sep 17 00:00:00 2001 From: WanderingPenwing Date: Sun, 14 Jul 2024 16:05:03 +0200 Subject: [PATCH] fixed channel renaming and self notifications --- Cargo.toml | 2 +- README.md | 13 ++++++++++++- src/bot.rs | 6 +++++- src/discord_structure.rs | 12 +++++++----- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1817c80..e7491d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jiji" -version = "0.1.0" +version = "1.0.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index edf8221..5d422e5 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ using egui to have immediate mod rendering (so the app is using very few process # Discord Backend using Serenity, with a discord bot (you need to have a token) -# Screeshots +# Screenshot ![screenshot](./assets/screenshot.png) # Features @@ -18,6 +18,17 @@ using Serenity, with a discord bot (you need to have a token) - no voice as we are using a bot - notifications : disabled by default, you enable them channel by channel +# Performances +best case (startup) / use case (100 messages loaded in current channel, 10 channels, 2 servers) + +ram usage : 105 MB / 109 MB + +frame calculation time : 0.3ms / 1ms with a Ryzen 7 3700U + +jiji is capped at 30 FPS (max 1 frame every 33.3ms) but 0.5 FPS when not interacted with (1 frame every 2000ms) + +that way it is very light on the processor as well + # Need further testing maybe able to use user token instead of bot token, but careful, you might get banned diff --git a/src/bot.rs b/src/bot.rs index dbdfe88..87d4353 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -47,7 +47,11 @@ impl EventHandler for Handler { sender.send(postman::Packet::Channel(private_channel)).expect("failed to send packet"); "dm".to_string() }; - let discord_message = discord_structure::Message::create(msg.id.to_string(), msg.channel_id.to_string(), guild_id, author_name, msg.content.clone(), msg.timestamp.to_rfc2822()).new(); + let mut discord_message = discord_structure::Message::create(msg.id.to_string(), msg.channel_id.to_string(), guild_id, author_name, msg.content.clone(), msg.timestamp.to_rfc2822()); + + if context.cache.current_user().await.id != msg.author.id { + discord_message.new(); + } sender.send(postman::Packet::Message(discord_message)).expect("failed to send packet"); } else { println!("bot : failed to retrieve sender"); diff --git a/src/discord_structure.rs b/src/discord_structure.rs index d373d9e..2fadb47 100644 --- a/src/discord_structure.rs +++ b/src/discord_structure.rs @@ -28,7 +28,11 @@ impl Guild { } already_exist = true; - self.channels[i].name = channel.name.clone(); + if self.channels[i].name.parse::().is_ok() { + self.channels[i].name = channel.name.clone(); + } else { + println!("discord_structure : channel already exist but name is not id '{}'",self.channels[i].name); + } if channel.notify && !self.channels[i].notify { self.channels[i].notify = true; @@ -171,9 +175,7 @@ impl Message { new: "".to_string(), } } - pub fn new(&mut self) -> Self { - let mut updated = self.clone(); - updated.new = "yes".to_string(); - updated + pub fn new(&mut self) { + self.new = "yes".to_string(); } } \ No newline at end of file