Init bot go.mod project and added queue system for bot actions handling

This commit is contained in:
2026-01-24 00:20:36 +03:00
parent 30c41d630e
commit 02039a14bd
3 changed files with 45 additions and 0 deletions

3
bot/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module lirqetes.ru/thelanc3/laura
go 1.25.4

37
bot/main.go Normal file
View File

@@ -0,0 +1,37 @@
package main
import (
"context"
"time"
"lirqetes.ru/thelanc3/laura/queue"
)
func main() {
ctx := context.Background()
actions := make(chan queue.BotAction, 200)
go actionsWorker(ctx, actions, 34*time.Millisecond)
}
func actionsWorker(
ctx context.Context,
actions <-chan queue.BotAction,
interval time.Duration,
) {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
{
return
}
case action := <-actions:
{
<-ticker.C
action(ctx)
}
}
}
}

5
bot/queue/bot_action.go Normal file
View File

@@ -0,0 +1,5 @@
package queue
import "context"
type BotAction func(ctx context.Context)