2019-10-03 20:22:22 +00:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2020-06-11 06:10:01 +00:00
|
|
|
|
2019-10-03 20:22:22 +00:00
|
|
|
"go.etztech.xyz/go-mcm/internal"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Log struct {
|
|
|
|
Chats Chats `json:"chats"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Chats struct {
|
|
|
|
Global []Entry `json:"global"`
|
|
|
|
Staff []Entry `json:"staff"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Entry struct {
|
|
|
|
Date string `json:"date"`
|
|
|
|
Text string `json:"text"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (web *Web) Log() (*Log, error) {
|
|
|
|
endpoint := fmt.Sprintf("%s?api=%s", web.endpoint("log"), web.Token)
|
|
|
|
log := &Log{}
|
|
|
|
|
|
|
|
resp, err := internal.ResponseGet(endpoint)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = json.Unmarshal(resp, &log)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return log, nil
|
|
|
|
}
|