time
This commit is contained in:
parent
ed938b2f4b
commit
a7281f189b
13
main.go
13
main.go
@ -4,6 +4,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"gopkg.in/gcfg.v1"
|
||||
|
||||
@ -11,12 +12,12 @@ import (
|
||||
)
|
||||
|
||||
type ChatWarsMessage struct {
|
||||
UserID64 int64 `json:"user_id"`
|
||||
SenderUserID64 int64 `json:"sender_user_id"`
|
||||
Date int32 `json:"date"`
|
||||
ID64 int64 `json:"id"`
|
||||
ChatID64 int64 `json:"chat_id"`
|
||||
Text string `json:"text"`
|
||||
UserID64 int64 `json:"user_id"`
|
||||
SenderUserID64 int64 `json:"sender_user_id"`
|
||||
Date time.Time `json:"date"`
|
||||
ID64 int64 `json:"id"`
|
||||
ChatID64 int64 `json:"chat_id"`
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
const user_chtwrsbot = 408101137
|
||||
|
11
td.go
11
td.go
@ -37,12 +37,14 @@ func ListenCW(c *tdlib.Client) {
|
||||
m := ChatWarsMessage{
|
||||
UserID64: ownUserID64,
|
||||
SenderUserID64: int64(updateMsg.Message.SenderUserID),
|
||||
Date: updateMsg.Message.Date,
|
||||
ID64: updateMsg.Message.ID,
|
||||
ChatID64: updateMsg.Message.ChatID,
|
||||
Text: txt,
|
||||
}
|
||||
|
||||
i, err := strconv.ParseInt(updateMsg.Message.Date, 10, 64)
|
||||
m.Date = time.Unix(i, 0)
|
||||
|
||||
MQCWMsgQueue <- m
|
||||
|
||||
fmt.Printf("[%d-%02d-%02d %02d:%02d:%02d-00:00]", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second())
|
||||
@ -115,21 +117,24 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) {
|
||||
m = ChatWarsMessage{
|
||||
UserID64: ownUserID64,
|
||||
SenderUserID64: int64(msg.SenderUserID),
|
||||
Date: msg.Date,
|
||||
ID64: msg.ID,
|
||||
ChatID64: msg.ChatID,
|
||||
Text: msg.Content.(*tdlib.MessageText).Text.Text,
|
||||
}
|
||||
i, err := strconv.ParseInt(msg.Date, 10, 64)
|
||||
m.Date = time.Unix(i, 0)
|
||||
} else {
|
||||
if msg.ForwardInfo.GetMessageForwardInfoEnum() == tdlib.MessageForwardedFromUserType {
|
||||
m = ChatWarsMessage{
|
||||
UserID64: int64(msg.SenderUserID),
|
||||
SenderUserID64: int64(msg.ForwardInfo.(*tdlib.MessageForwardedFromUser).SenderUserID),
|
||||
Date: msg.ForwardInfo.(*tdlib.MessageForwardedFromUser).Date,
|
||||
ID64: msg.ID,
|
||||
ChatID64: 0,
|
||||
Text: msg.Content.(*tdlib.MessageText).Text.Text,
|
||||
}
|
||||
i, err := strconv.ParseInt(msg.ForwardInfo.(*tdlib.MessageForwardedFromUser).Date, 10, 64)
|
||||
m.Date = time.Unix(i, 0)
|
||||
|
||||
} else {
|
||||
m = ChatWarsMessage{
|
||||
ID64: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user