Skip to content

Commit d8342a4

Browse files
committed
Replace Docker build-and-run script with .Net Core script
The Docker build-and-run.sh script was deleted and replaced with a new StartGolfClapBot.bat script that updates a Git repository and runs a .Net Core program. Additionally, a random delay was introduced before the bot sends messages in TwitchWorker.cs to reduce bot spamming. The delay varies between 8 and 12 seconds.
1 parent 9578ef5 commit d8342a4

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

StartGolfClapBot.bat

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@REM @echo off
2+
REM This is a Windows batch script to update a Git repository and run a .NET Core program
3+
4+
REM Specify the path to your Git repository
5+
set repo_directory=C:\repos\GolfClapBot
6+
7+
REM Change to the Git repository directory
8+
cd /d %repo_directory%
9+
10+
REM Pull the latest changes from the default branch (e.g., 'main' or 'master')
11+
git pull
12+
13+
REM Check if the 'dotnet' command is available
14+
where dotnet > nul 2>&1
15+
if %errorlevel% neq 0 (
16+
echo Error: .NET Core SDK is not installed or not in the system PATH.
17+
pause
18+
exit /b 1
19+
)
20+
21+
REM Specify the path to your .NET Core project directory
22+
set project_directory=C:\repos\GolfClapBot\src\GolfClapBot.Runner
23+
set publish_directory=C:\repos\GolfClapBot\src\GolfClapBot.Runner\bin\Release\net8.0\publish
24+
25+
REM Change to the .NET Core project directory
26+
cd /d %project_directory%
27+
28+
REM Publish the .NET Core project
29+
dotnet publish
30+
31+
REM Change to the publish directory
32+
cd /d %publish_directory%
33+
34+
REM Run the .NET Core program
35+
start GolfClapBot.Runner.exe
36+
37+
REM Exit the script
38+
exit /b 0

build-and-run.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/GolfClapBot.Runner/TwitchWorker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ private async Task TwitchClientOnMessageReceived(object? sender, OnMessageReceiv
7575
return;
7676
}
7777

78-
if (_sentMessages.Exists(message => message.TmiSent > DateTime.UtcNow.AddSeconds(-5)))
78+
if (_sentMessages.Exists(message =>
79+
message.TmiSent > DateTime.UtcNow.AddSeconds(-new Random().Next(8, 12))))
7980
{
8081
_logger.LogInformation("Bot has already sent a message in the last 5 seconds");
8182

0 commit comments

Comments
 (0)