2019-06-26 10:56:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
room "git.fromouter.space/mcg/cardgage/room/api"
|
|
|
|
)
|
|
|
|
|
|
|
|
type draftBot struct {
|
2019-06-27 11:49:57 +00:00
|
|
|
Name string
|
2019-06-26 10:56:02 +00:00
|
|
|
Sessions map[string]session
|
|
|
|
}
|
|
|
|
|
2019-06-27 11:49:57 +00:00
|
|
|
func newDraftBot(name string) *draftBot {
|
2019-06-26 10:56:02 +00:00
|
|
|
return &draftBot{
|
2019-06-27 11:49:57 +00:00
|
|
|
Name: name,
|
2019-06-26 10:56:02 +00:00
|
|
|
Sessions: make(map[string]session),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *draftBot) onMessage(msg room.ServerMessage) {
|
|
|
|
switch msg.Type {
|
|
|
|
case room.MsgMessage:
|
2019-06-27 11:49:57 +00:00
|
|
|
if *logAll {
|
|
|
|
logger.Log("event", "message",
|
|
|
|
"roomid", msg.RoomID,
|
|
|
|
"from", msg.Message.From,
|
|
|
|
"to", msg.Message.To,
|
|
|
|
"content", msg.Message.Message)
|
|
|
|
}
|
|
|
|
// Only consider messages that speak directly to me
|
|
|
|
if msg.Message.To == d.Name {
|
|
|
|
d.handleMessage(*msg.Message)
|
|
|
|
}
|
2019-06-26 10:56:02 +00:00
|
|
|
case room.MsgEvent:
|
2019-06-27 11:49:57 +00:00
|
|
|
if *logAll {
|
|
|
|
logger.Log("event", "event",
|
|
|
|
"roomid", msg.RoomID,
|
|
|
|
"content", msg.Event.Message)
|
|
|
|
}
|
2019-06-26 10:56:02 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-27 11:49:57 +00:00
|
|
|
|
|
|
|
func (d *draftBot) handleMessage(msg room.Message) {
|
|
|
|
//TODO
|
|
|
|
}
|