mirror of
https://github.com/HugeFrog24/go-telegram-bot.git
synced 2026-03-02 00:14:34 +00:00
md formatting doesnt work yet Started implementing owner feature Add .gitattributes to enforce LF line endings Temporary commit before merge Updated owner management Updated json and gitignore Proceed with role management Again, CI Fix some lint errors Implemented screening Per-bot API keys implemented Use getRoleByName func Fix unused imports Upgrade actions rm unused function Upgrade action Fix unaddressed errors
33 lines
685 B
Go
33 lines
685 B
Go
// clock.go
|
|
package main
|
|
|
|
import "time"
|
|
|
|
// Clock is an interface to abstract time-related functions.
|
|
type Clock interface {
|
|
Now() time.Time
|
|
}
|
|
|
|
// RealClock implements Clock using the actual time.
|
|
type RealClock struct{}
|
|
|
|
// Now returns the current local time.
|
|
func (RealClock) Now() time.Time {
|
|
return time.Now()
|
|
}
|
|
|
|
// MockClock implements Clock for testing purposes.
|
|
type MockClock struct {
|
|
currentTime time.Time
|
|
}
|
|
|
|
// Now returns the mocked current time.
|
|
func (mc *MockClock) Now() time.Time {
|
|
return mc.currentTime
|
|
}
|
|
|
|
// Advance moves the current time forward by the specified duration.
|
|
func (mc *MockClock) Advance(d time.Duration) {
|
|
mc.currentTime = mc.currentTime.Add(d)
|
|
}
|