forked from johansundell/cocbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworldtime.go
More file actions
41 lines (38 loc) · 1 KB
/
worldtime.go
File metadata and controls
41 lines (38 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"context"
"fmt"
"log"
"strings"
"time"
)
func init() {
key := commandFunc{"!world time", "Show some of our members time", "", categoryFun}
lockMap.Lock()
defer lockMap.Unlock()
botFuncs[key] = func(ctx context.Context, command string) (string, error) {
if strings.Contains(command, key.command) {
m := make(map[string]string)
m["Asia/Calcutta"] = "Brown, George and K2"
m["Europe/Stockholm"] = "Sudde"
m["Asia/Jakarta"] = "Tommy"
m["US/Eastern"] = "James and Blac"
m["Europe/London"] = "Stube, Blackfear, Sway and E1lioT"
m["US/Central"] = "wjn2448"
m["Canada/Pacific"] = "Heliloggerjay"
msg := ""
t := time.Now()
for k, v := range m {
l, err := time.LoadLocation(k)
if err != nil {
log.Println(err)
continue
}
msg += fmt.Sprintf("The time for %s is %s\n", v, t.In(l).Format("15:04"))
}
msg += fmt.Sprintf("The time for Jon in Coordinated Mars Time (MTC) is %s\n", getMarsTime())
return msg, nil
}
return "", nil
}
}