Prevent getting stuck in AdminAccess mode
This commit is contained in:
parent
86a579714e
commit
f2ed53a930
26
src/bot.rs
26
src/bot.rs
@ -17,12 +17,8 @@ use tokio::runtime::Runtime;
|
|||||||
use vek::Quaternion;
|
use vek::Quaternion;
|
||||||
use veloren_client::{addr::ConnectionArgs, Client, Event as VelorenEvent, SiteInfoRich, WorldExt};
|
use veloren_client::{addr::ConnectionArgs, Client, Event as VelorenEvent, SiteInfoRich, WorldExt};
|
||||||
use veloren_common::{
|
use veloren_common::{
|
||||||
character::Character,
|
|
||||||
clock::Clock,
|
clock::Clock,
|
||||||
comp::{
|
comp::{invite::InviteKind, item::ItemDefinitionIdOwned, ChatType, ControllerInputs, Ori, Pos},
|
||||||
invite::InviteKind, item::ItemDefinitionIdOwned, CharacterState, ChatType,
|
|
||||||
ControllerInputs, Health, Ori, Pos,
|
|
||||||
},
|
|
||||||
outcome::Outcome,
|
outcome::Outcome,
|
||||||
time::DayPeriod,
|
time::DayPeriod,
|
||||||
trade::{PendingTrade, TradeAction, TradeResult},
|
trade::{PendingTrade, TradeAction, TradeResult},
|
||||||
@ -174,14 +170,18 @@ impl Bot {
|
|||||||
}
|
}
|
||||||
TradeMode::Trade => self.handle_trade(trade.clone())?,
|
TradeMode::Trade => self.handle_trade(trade.clone())?,
|
||||||
}
|
}
|
||||||
// It should be enough to check the trade mode but the extra check for outgoing
|
// The extra check for outgoing invites ensures that the bot doesn't give admin access
|
||||||
// invites ensures that the bot doesn't accept an invite while in AdminAccess mode.
|
// to a non-admin user. This cannot happen because the bot doesn't send invites in
|
||||||
// This cannot happen because the bot doesn't send invites in Trade mode but the code
|
// Trade mode but the code is here to be extra safe for future refactoring.
|
||||||
// is here to be extra safe for future refactoring.
|
} else if self.client.pending_invites().is_empty() {
|
||||||
} else if TradeMode::Trade == self.trade_mode
|
match self.trade_mode {
|
||||||
&& self.client.pending_invites().is_empty()
|
TradeMode::AdminAccess => {
|
||||||
{
|
self.trade_mode = TradeMode::Trade;
|
||||||
self.client.accept_invite();
|
}
|
||||||
|
TradeMode::Trade => {
|
||||||
|
self.client.accept_invite();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.sort_count > 0 {
|
if self.sort_count > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user