From e450c7ced4589625c5ee2d9dccfaee42c81f538e Mon Sep 17 00:00:00 2001 From: shoopea Date: Fri, 3 May 2019 19:35:05 +0800 Subject: [PATCH] direction --- main.go | 19 +++++-------------- td.go | 6 +----- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index e9bf94b..383e8b3 100644 --- a/main.go +++ b/main.go @@ -11,19 +11,12 @@ import ( "github.com/Arman92/go-tdlib" ) -type MsgDirection string - -const ( - Incoming MsgDirection = `incoming` - Outgoing MsgDirection = `outgoing` -) - type ChatWarsMessage struct { - MsgID64 int64 `json:"msg_id"` - UserID64 int64 `json:"user_id"` - Direction MsgDirection `json:"direction"` - MsgText string `json:"msg"` - MsgDate int32 `json:"date"` + MsgID64 int64 `json:"msg_id"` + ChatID64 int64 `json:"chat_id"` + UserID64 int64 `json:"user_id"` + MsgText string `json:"msg"` + MsgDate int32 `json:"date"` } const user_chtwrsbot = 408101137 @@ -108,8 +101,6 @@ func main() { } } - log.Println("Poof ..") - ownUserID32 = OwnUserID(client) ownUserID64 = int64(OwnUserID(client)) diff --git a/td.go b/td.go index 1867993..cd7b1b9 100644 --- a/td.go +++ b/td.go @@ -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)