fix start bug and timing tuning

This commit is contained in:
Green Sky 2024-02-01 01:31:34 +01:00
parent eba657c484
commit 4dc877ef68
No known key found for this signature in database
2 changed files with 13 additions and 1 deletions

View File

@ -307,7 +307,11 @@ bool RPBot::onEvent(const Message::Events::MessageConstruct& e) {
auto& timeout = _cr.get<StateIdle>(rpbot_contact).timeout; auto& timeout = _cr.get<StateIdle>(rpbot_contact).timeout;
// TODO: config with id // TODO: config with id
timeout = std::min<float>(timeout, _conf.get_double("RPBot", "max_interactive_delay").value_or(4.f)); timeout = std::clamp<float>(
timeout,
1.5f, // minimum, helps when activly history syncing
_conf.get_double("RPBot", "max_interactive_delay").value_or(4.f)
);
std::cout << "RPBot: onMsg new timeout: " << timeout << "\n"; std::cout << "RPBot: onMsg new timeout: " << timeout << "\n";
return false; return false;

View File

@ -65,6 +65,14 @@ void RPBot::registerCommands(void) {
auto view = _cr.view<Contact::Components::ID>(); auto view = _cr.view<Contact::Components::ID>();
for (auto it = view.begin(), it_end = view.end(); it != it_end; it++) { for (auto it = view.begin(), it_end = view.end(); it != it_end; it++) {
if (view.get<Contact::Components::ID>(*it).data == id_bin) { if (view.get<Contact::Components::ID>(*it).data == id_bin) {
if (_cr.any_of<StateIdle, StateNextActor, StateGenerateMsg, StateTimingCheck>(*it)) {
_rmm.sendText(
contact_from,
"RPBot already running"
);
return true;
}
auto& new_state = _cr.emplace<StateIdle>(*it); auto& new_state = _cr.emplace<StateIdle>(*it);
new_state.timeout = 10.f; new_state.timeout = 10.f;