39 lines
595 B
Go
39 lines
595 B
Go
|
package web
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"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
|
||
|
}
|