direction

This commit is contained in:
shoopea 2019-05-03 19:35:05 +08:00
parent 2693ad9bd6
commit e450c7ced4
2 changed files with 6 additions and 19 deletions

11
main.go
View File

@ -11,17 +11,10 @@ import (
"github.com/Arman92/go-tdlib"
)
type MsgDirection string
const (
Incoming MsgDirection = `incoming`
Outgoing MsgDirection = `outgoing`
)
type ChatWarsMessage struct {
MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"`
UserID64 int64 `json:"user_id"`
Direction MsgDirection `json:"direction"`
MsgText string `json:"msg"`
MsgDate int32 `json:"date"`
}
@ -108,8 +101,6 @@ func main() {
}
}
log.Println("Poof ..")
ownUserID32 = OwnUserID(client)
ownUserID64 = int64(OwnUserID(client))

6
td.go
View File

@ -154,15 +154,11 @@ func getHistory(c *tdlib.Client) {
case tdlib.MessageTextType:
m := ChatWarsMessage{
UserID64: int64(msg.SenderUserID),
ChatID64: msg.ChatID
MsgDate: msg.Date,
MsgText: msg.Content.(*tdlib.MessageText).Text.Text,
MsgID64: msg.ID,
}
if msg.SenderUserID == ownUserID32 {
m.Direction = Outgoing
} else {
m.Direction = Incoming
}
b, _ := json.Marshal(m)