feat: add dig command

Other changes:
- use middleware for permission checking
- able to respond with emoji
- log incoming requests
This commit is contained in:
Yiyang Kang 2022-11-23 04:05:39 +08:00
parent 412725c6b9
commit 37dffe56ce
3 changed files with 285 additions and 7 deletions

18
utils/utils.go Normal file
View file

@ -0,0 +1,18 @@
package utils
func WaitFor(fn func()) <-chan struct{} {
ch := make(chan struct{})
go func() {
defer close(ch)
fn()
}()
return ch
}
func ToLookupMap[T comparable](s []T) map[T]struct{} {
m := make(map[T]struct{}, len(s))
for _, item := range s {
m[item] = struct{}{}
}
return m
}