Skip to content

Commit

Permalink
feat: list non-emoji tags at the end of the message
Browse files Browse the repository at this point in the history
  • Loading branch information
arcuru committed Oct 10, 2024
1 parent f5c9156 commit 4397a22
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::utils::*;

use anyhow::Context;
use clap::error::Result;
use emojis::Emoji;
use matrix_sdk::ruma::events::room::message::RoomMessageEventContent;

use matrix_sdk::ruma::events::tag::TagInfo;
Expand Down Expand Up @@ -400,18 +399,22 @@ async fn daemon_poke(

// Add emojis
if let Some(tags) = poke_request.tags {
let emojis_vec: Vec<&'static Emoji> = tags
.iter()
.filter_map(|shortcode| emojis::get_by_shortcode(shortcode.as_str()))
.collect();
let emojis_str = emojis_vec
.iter()
.map(|e| e.to_string())
.collect::<Vec<String>>()
.join("");
let mut emojis_str = String::new();
let mut non_emojis = Vec::new();
for shortcode in tags {
if let Some(emoji) = emojis::get_by_shortcode(shortcode.as_str()) {
emojis_str.push_str(emoji.as_ref());
} else {
non_emojis.push(shortcode);
}
}
if !emojis_str.is_empty() {
poke_request.message = format!("{emojis_str} {}", poke_request.message);
}
if !non_emojis.is_empty() {
poke_request.message =
format!("{}\nTags: {}", poke_request.message, non_emojis.join(", "));
}
}

// If the room is a room name in the config, we'll transform it to the room id.
Expand Down

0 comments on commit 4397a22

Please sign in to comment.