feat: approve button

This commit is contained in:
Vaala Cat
2023-08-28 15:57:58 +08:00
parent 46cf57764c
commit 5528766c13
15 changed files with 469 additions and 176 deletions

39
defs/callback.go Normal file
View File

@@ -0,0 +1,39 @@
package defs
import "encoding/json"
type Command struct {
Command string `json:"Command"`
Argstr string `json:"Argstr"`
}
func (c *Command) ToJSON() string {
ans, _ := json.Marshal(c)
return string(ans)
}
const (
CMD_UNKNOWN = "unknown"
CMD_APPROVE = "approve"
CMD_REJECT = "reject"
)
func NewApproveCommand(mcName string) *Command {
return &Command{
Command: CMD_APPROVE,
Argstr: mcName,
}
}
func NewRejectCommand(mcName string) *Command {
return &Command{
Command: CMD_REJECT,
Argstr: mcName,
}
}
func NewCommandFromJSON(jsonStr string) (*Command, error) {
var cmd Command
err := json.Unmarshal([]byte(jsonStr), &cmd)
return &cmd, err
}