ignore messages sent from self
This commit is contained in:
parent
8729cd0e64
commit
de71131f6f
1 changed files with 16 additions and 2 deletions
18
src/main.rs
18
src/main.rs
|
@ -150,7 +150,16 @@ async fn auto_join(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn on_room_message(event: SyncMessageEvent<MessageEventContent>, room: Room) -> Result<()> {
|
||||
async fn on_room_message(
|
||||
event: SyncMessageEvent<MessageEventContent>,
|
||||
room: Room,
|
||||
client: Client,
|
||||
) -> Result<()> {
|
||||
// Ignore messages sent from self.
|
||||
if client.user_id().await.as_ref() == Some(&event.sender) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Room::Joined(room) = room {
|
||||
parse_message(event, room).await?;
|
||||
}
|
||||
|
@ -229,7 +238,12 @@ async fn source(room: Joined) -> Result<()> {
|
|||
}
|
||||
|
||||
async fn uwuify(room: Joined, message: &str) -> Result<()> {
|
||||
let content = MessageEventContent::text_plain(uwuifier::uwuify_str_sse(message));
|
||||
let message = if message.is_empty() {
|
||||
"uwu".to_owned()
|
||||
} else {
|
||||
uwuifier::uwuify_str_sse(message)
|
||||
};
|
||||
let content = MessageEventContent::text_plain(message);
|
||||
room.send(content, None).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue