Don't include quote when judging replies

This commit is contained in:
0xf8 2023-04-23 12:21:41 -04:00
parent b2f59a0990
commit f60d7f29bf
Signed by: 0xf8
GPG Key ID: 446580D758689584

View File

@ -77,9 +77,8 @@ async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) -> any
return Ok(());
}
let judgement = judge::Judgement { text: text_content };
// Handle replies
let mut is_reply = false;
if let Some(relation) = orig_event.to_owned().content.relates_to {
if let Some(event) = match relation {
Relation::Reply { in_reply_to } => {
@ -97,6 +96,13 @@ async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) -> any
} {
let event = event.as_original().unwrap();
let content = event.content.to_owned().body().to_lowercase();
is_reply = true;
let reply_end = content.find("\n\n");
let content = match reply_end {
Some(r) => content.get(r+2..).unwrap().to_string(),
None => content,
};
if !debug
&& event.sender
@ -135,6 +141,16 @@ async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) -> any
}
}
let judgement = if is_reply {
let reply_end = text_content.find("\n\n");
judge::Judgement { text: match reply_end {
Some(r) => text_content.get(r+2..).unwrap().to_string(),
None => text_content,
}}
} else {
judge::Judgement { text: text_content }
};
let judgement = judgement.judge(&config)?;
match judgement.0 {
judge::JudgementResult::Ok => return Ok(()),