mirror of
https://github.com/lyx0/nourybot-matrix.git
synced 2024-11-13 19:49:54 +01:00
add uptime to ping command
This commit is contained in:
parent
4f64910e5d
commit
665e6b95ea
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"github.com/chzyer/readline"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/lyx0/nourybot-matrix/internal/common"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/rs/zerolog"
|
||||
"maunium.net/go/mautrix"
|
||||
|
@ -69,6 +70,8 @@ func main() {
|
|||
|
||||
var lastRoomID id.RoomID
|
||||
|
||||
common.StartTime()
|
||||
|
||||
app := &Application{
|
||||
Mc: client,
|
||||
Log: log,
|
||||
|
|
1
go.mod
1
go.mod
|
@ -12,6 +12,7 @@ require (
|
|||
|
||||
require (
|
||||
github.com/briandowns/openweathermap v0.19.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||
github.com/shkh/lastfm-go v0.0.0-20191215035245-89a801c244e0 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -9,6 +9,8 @@ github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
|
|||
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
func Ping() (string, error) {
|
||||
n := common.GetCommandsUsed()
|
||||
resp := fmt.Sprintf("Pong! Commands used: %v", n)
|
||||
up := common.GetUptime()
|
||||
resp := fmt.Sprintf("Pong! Commands used: %v Last restart: %v", n, up)
|
||||
return resp, nil
|
||||
}
|
||||
|
|
19
internal/common/uptime.go
Normal file
19
internal/common/uptime.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"github.com/dustin/go-humanize"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
uptime time.Time
|
||||
)
|
||||
|
||||
func StartTime() {
|
||||
uptime = time.Now()
|
||||
}
|
||||
|
||||
func GetUptime() string {
|
||||
h := humanize.Time(uptime)
|
||||
return h
|
||||
}
|
Loading…
Reference in a new issue