Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

add chat warning delay option #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tf2_bot_detector/Config/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ void Settings::LoadFile()
try_get_to_defaulted(*found, m_AutoChatWarningsConnecting, "auto_chat_warnings_connecting", DEFAULTS.m_AutoChatWarningsConnecting);
try_get_to_defaulted(*found, m_AutoVotekick, "auto_votekick", DEFAULTS.m_AutoVotekick);
try_get_to_defaulted(*found, m_AutoVotekickDelay, "auto_votekick_delay", DEFAULTS.m_AutoVotekickDelay);
try_get_to_defaulted(*found, m_ChatWarningInterval, "chat_warning_interval", DEFAULTS.m_ChatWarningInterval);
try_get_to_defaulted(*found, m_AutoMark, "auto_mark", DEFAULTS.m_AutoMark);
try_get_to_defaulted(*found, m_LazyLoadAPIData, "lazy_load_api_data", DEFAULTS.m_LazyLoadAPIData);

Expand Down
2 changes: 2 additions & 0 deletions tf2_bot_detector/Config/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace tf2_bot_detector
bool m_AutoChatWarningsConnecting = false;
bool m_AutoVotekick = true;
float m_AutoVotekickDelay = 15;
float m_ChatWarningInterval = 20;
bool m_AutoMark = true;

bool m_SleepWhenUnfocused = true;
Expand All @@ -67,6 +68,7 @@ namespace tf2_bot_detector
ProgramUpdateCheckMode m_ProgramUpdateCheckMode = ProgramUpdateCheckMode::Unknown;

constexpr auto GetAutoVotekickDelay() const { return std::chrono::duration<float>(m_AutoVotekickDelay); }
constexpr auto GetChatWarningInterval() const { return std::chrono::milliseconds((int)(m_ChatWarningInterval * 1000)); }

const std::string& GetSteamAPIKey() const { return m_SteamAPIKey; }
void SetSteamAPIKey(std::string key);
Expand Down
2 changes: 1 addition & 1 deletion tf2_bot_detector/ModeratorLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ void ModeratorLogic::HandleConnectedEnemyCheaters(const std::vector<Cheater>& en
if (m_Settings->m_AutoChatWarnings && m_ActionManager->QueueAction<ChatMessageAction>(chatMsg))
{
Log({ 1, 0, 0, 1 }, logMsg);
m_NextCheaterWarningTime = now + CHEATER_WARNING_INTERVAL;
m_NextCheaterWarningTime = now + m_Settings->GetChatWarningInterval();
}
}
else
Expand Down
8 changes: 8 additions & 0 deletions tf2_bot_detector/UI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ void MainWindow::OnDrawSettingsPopup()
"This is needed because players can't vote until they have joined a team and picked a class. If we call a vote before enough people are ready, it might fail.");
}

// Chat warning interval
{
if (ImGui::SliderFloat("Chat warning interval", &m_Settings.m_ChatWarningInterval, 20, 60, "%1.1f seconds"))
m_Settings.SaveFile();
ImGui::SetHoverTooltip("Interval between chat warnings.\n\n"
"Increase it if you feel that you are spamming too much.");
}

// Send warnings for connecting cheaters
{
if (ImGui::Checkbox("Chat message warnings for connecting cheaters", &m_Settings.m_AutoChatWarningsConnecting))
Expand Down