fixed channel renaming and self notifications

This commit is contained in:
WanderingPenwing 2024-07-14 16:05:03 +02:00
parent e24b8788b8
commit fedd8ce179
4 changed files with 25 additions and 8 deletions

View file

@ -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

View file

@ -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

View file

@ -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");

View file

@ -28,7 +28,11 @@ impl Guild {
}
already_exist = true;
if self.channels[i].name.parse::<u64>().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();
}
}