Some cool features

This commit is contained in:
Jonathan Flueren 2023-07-06 17:09:22 +02:00
parent e6d819d7a8
commit b7f0b50aad
2 changed files with 37 additions and 5 deletions

BIN
a.out

Binary file not shown.

View file

@ -3,10 +3,10 @@ use std::{env, process::exit};
use matrix_sdk::{ use matrix_sdk::{
config::SyncSettings, config::SyncSettings,
room::Room, room::Room,
ruma::events::room::{ ruma::events::{room::{
member::StrippedRoomMemberEvent, member::StrippedRoomMemberEvent,
message::{MessageType, OriginalSyncRoomMessageEvent, RoomMessageEventContent}, message::{MessageType, OriginalSyncRoomMessageEvent, RoomMessageEventContent},
}, }, relation::Annotation, reaction::ReactionEventContent},
Client, Client,
}; };
use tokio::time::{sleep, Duration}; use tokio::time::{sleep, Duration};
@ -145,11 +145,43 @@ async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) {
println!("sending"); println!("sending");
// send our message to the room we found the "!party" command in
// the last parameter is an optional transaction id which we don't
// care about.
room.send(content, None).await.unwrap(); room.send(content, None).await.unwrap();
println!("message sent"); println!("message sent");
} }
/*
if text_content.body.contains("!timo") || text_content.body.contains("!Timo") {
let content = RoomMessageEventContent::text_plain("☢️☢️☢️");
println!("sending");
room.send(content, None).await.unwrap();
println!("message sent");
}*/
if text_content.body.contains("!timo") {
let reaction = ReactionEventContent::new(
Annotation::new(
event.event_id.to_owned(),
"TIMO".to_owned()
)
);
room.send(reaction, None).await.unwrap();
}
if text_content.body.contains("\\") {
let reaction = ReactionEventContent::new(
Annotation::new(
event.event_id.to_owned(),
text_content.body.replace("\\", "λ").replace("!lambda ","").to_owned()
)
);
room.send(reaction, None).await.unwrap();
}
} }