Make bot reject invite if it fails

This commit is contained in:
0xf8 2023-04-16 22:22:06 -04:00
parent 2928e21873
commit 54efdafd11
Signed by: 0xf8
GPG Key ID: 446580D758689584

View File

@ -37,17 +37,10 @@ async fn on_stripped_state_member(room_member: StrippedRoomMemberEvent, client:
if let Room::Invited(room) = room {
tokio::spawn(async move {
let mut delay = 2;
while let Err(err) = room.accept_invitation().await {
eprintln!("Warn: {} ({err:?}), retrying in {delay}s", room.room_id());
sleep(Duration::from_secs(delay)).await;
delay *= 2;
if delay > 3600 {
eprintln!("Warn: {} ({err:?})", room.room_id());
break;
if let Err(err) = room.accept_invitation().await {
eprintln!("Err: {err:?}");
if let Err(e) = room.reject_invitation().await {
eprintln!("Err: {e:?}");
}
}
});