package main import ( "crypto/md5" "encoding/base32" "encoding/json" "fmt" "math/rand" "regexp" "strconv" "strings" "sync" "time" "github.com/Arman92/go-tdlib" // "github.com/go-web/tokenizer" // "database/sql" // _ "github.com/go-sql-driver/mysql" ) type ChatWarsWithdraw struct { Item string `json:"item"` Quantity int64 `json:"quantity"` UserID64 int64 `json:"user_id"` Time time.Time `json:"time"` } const user_chtwrsbot = 408101137 const user_botnestbot = 541634211 const user_chtwrscastlebot = 526586204 const chat_darkwing = -1001152534174 const chat_guild_deposit = -1001179598662 const chat_guild = -1001152534174 const chat_private = -1001092914472 var ownUserID64 = int64(0) var ownUserID32 = int32(0) var msgMutex sync.Mutex var msgID64 = int64(0) var msgUserID64 = int64(0) var msgText string var vault Vault var size int var withdrawItem string var withdrawUserID64 int64 var withdrawTime time.Time var aesKey []byte var hmacKey []byte var withdrawals = map[string]ChatWarsWithdraw{} var TgEncoding *base32.Encoding func main() { // msgMutex = &sync.Mutex{} tdlib.SetLogVerbosityLevel(1) tdlib.SetFilePath("./errors.txt") TgEncoding = base32.StdEncoding.WithPadding(base32.NoPadding) // Create new instance of client client := tdlib.NewClient(tdlib.Config{ APIID: "187786", APIHash: "e782045df67ba48e441ccb105da8fc85", SystemLanguageCode: "en", DeviceModel: "Shoogram", SystemVersion: "1.3.3.7", ApplicationVersion: "3.1.3.3.7", UseMessageDatabase: true, UseFileDatabase: true, UseChatInfoDatabase: true, UseTestDataCenter: false, DatabaseDirectory: "./tdlib-db", FileDirectory: "./tdlib-files", IgnoreFileNames: false, }) for { currentState, _ := client.Authorize() if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPhoneNumberType { fmt.Print("Enter phone: ") var number string fmt.Scanln(&number) _, err := client.SendPhoneNumber(number) if err != nil { fmt.Printf("Error sending phone number: %v", err) } } else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitCodeType { fmt.Print("Enter code: ") var code string fmt.Scanln(&code) _, err := client.SendAuthCode(code) if err != nil { fmt.Printf("Error sending auth code : %v", err) } } else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateWaitPasswordType { fmt.Print("Enter Password: ") var password string fmt.Scanln(&password) _, err := client.SendAuthPassword(password) if err != nil { fmt.Printf("Error sending auth password: %v", err) } } else if currentState.GetAuthorizationStateEnum() == tdlib.AuthorizationStateReadyType { fmt.Println("Authorization Ready! Let's rock") break } } ownUserID32 = OwnUserID(client) ownUserID64 = int64(OwnUserID(client)) go PillageKnight(client) go ListenDarkwing(client) go ListenCW(client) // go ListenAll(client) go ListenGuild(client) // go ForwardOwnMsg(client) fmt.Println("Started !") // Main loop for { time.Sleep(30 * time.Second) } } func PillageKnight(c *tdlib.Client) { eventFilter := func(msg *tdlib.TdMessage) bool { updateMsg := (*msg).(*tdlib.UpdateNewMessage) chatID := updateMsg.Message.ChatID senderUserID := updateMsg.Message.SenderUserID // viaBotUserID := updateMsg.Message.ViaBotUserID // fmt.Println("UpdateNewMessage : chatID : ", chatID) // fmt.Println("UpdateNewMessage : senderUserID : ", senderUserID) // fmt.Println("UpdateNewMessage : viaBotUserID : ", viaBotUserID) if senderUserID == user_chtwrsbot && chatID == user_chtwrsbot { return true } return false } receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100) for newMsg := range receiver.Chan { updateMsg := (newMsg).(*tdlib.UpdateNewMessage) // senderUserID := updateMsg.Message.SenderUserID mType := updateMsg.Message.Content.GetMessageContentEnum() if mType == "messageText" { /* user, err := c.GetUser(senderUserID) if err != nil { fmt.Println("Pillage:", err.Error()) continue } */ txt := updateMsg.Message.Content.(*tdlib.MessageText).Text.Text for _, line := range strings.Split(strings.TrimSuffix(txt, "\n"), "\n") { match, _ := regexp.MatchString("You were strolling around on your horse.*To stop him click /go.*", line) if match { fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PILLAGE KNIGHT INCOMING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") time.Sleep(1 * time.Second) fwdMsg := ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, ownUserID64) delay := rand.Intn(20) fmt.Println("Delaying reply by", delay+5, "seconds") time.Sleep(time.Duration(delay) * time.Second) c.SetOption("online", tdlib.NewOptionValueBoolean(true)) time.Sleep(5 * time.Second) inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText("/go\n", nil), true, true) msgMutex.Lock() sendMsg, _ := c.SendMessage(updateMsg.Message.ChatID, 0, false, false, nil, inputMsgTxt) msgID64 = sendMsg.ID msgText = string("/go") fmt.Println("send msgID64 (go) : ", msgID64) delay = rand.Intn(10) + 20 time.Sleep(time.Duration(delay) * time.Second) inputMsgTxt = tdlib.NewInputMessageText(tdlib.NewFormattedText("πŸ›‘Defend\n", nil), true, true) msgMutex.Lock() sendMsg, _ = c.SendMessage(updateMsg.Message.ChatID, 0, false, false, nil, inputMsgTxt) msgID64 = sendMsg.ID msgText = string("πŸ›‘Defend") fmt.Println("send msgID64 (defend) : ", msgID64) time.Sleep(1 * time.Second) DeleteMsg(c, ownUserID64, fwdMsg) time.Sleep(7 * time.Second) // c.SetOption("online", tdlib.NewOptionValueBoolean(false)) break } match, _ = regexp.MatchString(".*/pledge.*", line) if match { fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PLEDGE INCOMING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") time.Sleep(1 * time.Second) fwdMsg := ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, ownUserID64) delay := rand.Intn(20) fmt.Println("Delaying reply by", delay, "seconds") time.Sleep(time.Duration(delay) * time.Second) c.SetOption("online", tdlib.NewOptionValueBoolean(true)) time.Sleep(5 * time.Second) inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText("/pledge\n", nil), true, true) msgMutex.Lock() sendMsg, _ := c.SendMessage(updateMsg.Message.ChatID, 0, false, false, nil, inputMsgTxt) msgID64 = sendMsg.ID msgText = string("/pledge") fmt.Println("send msgID64 (pledge) : ", msgID64) time.Sleep(1 * time.Second) DeleteMsg(c, ownUserID64, fwdMsg) time.Sleep(7 * time.Second) // c.SetOption("online", tdlib.NewOptionValueBoolean(false)) break } } } } } func ListenCW(c *tdlib.Client) { var msgDisplay, msgDelete bool eventFilter := func(msg *tdlib.TdMessage) bool { updateMsg := (*msg).(*tdlib.UpdateNewMessage) chatID := updateMsg.Message.ChatID senderUserID := updateMsg.Message.SenderUserID if senderUserID == user_chtwrsbot && chatID == user_chtwrsbot { return true } return false } receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100) for newMsg := range receiver.Chan { updateMsg := (newMsg).(*tdlib.UpdateNewMessage) senderUserID := updateMsg.Message.SenderUserID mType := updateMsg.Message.Content.GetMessageContentEnum() if mType == "messageText" { user, err := c.GetUser(senderUserID) if err != nil { fmt.Println("ListenCW:", err.Error()) continue } txt := updateMsg.Message.Content.(*tdlib.MessageText).Text.Text fmt.Println("============== CHAT WARS (", user.Username, ") ================================================================") fmt.Println(txt, "\n") fmt.Println("===============================================================================================================") fmt.Println("recv msgID64 : ", msgID64) if msgID64 != int64(0) { switch msgText { case "/g_stock_res": vault.Res = string(txt) msgDisplay = false msgDelete = true case "/g_stock_alch": vault.Alch = string(txt) msgDisplay = false msgDelete = true case "/g_stock_misc": vault.Misc = string(txt) msgDisplay = false msgDelete = true case "/g_stock_rec": vault.Rec = string(txt) msgDisplay = false msgDelete = true case "/g_stock_parts": vault.Parts = string(txt) msgDisplay = false msgDelete = true case "/g_stock_other": vault.Other = string(txt) msgDisplay = false msgDelete = true case "/g_withdraw": time.Sleep(1 * time.Second) _ = ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, msgUserID64) msgDisplay = false msgDelete = false default: fmt.Println("No specific task for ", msgText) msgDisplay = true msgDelete = false } time.Sleep(1 * time.Second) if msgDelete { DeleteMsg(c, user_chtwrsbot, msgID64) time.Sleep(1 * time.Second) DeleteMsg(c, user_chtwrsbot, updateMsg.Message.ID) } msgID64 = int64(0) msgUserID64 = int64(0) msgMutex.Unlock() } else { msgDisplay = true } if msgDisplay { for _, line := range strings.Split(strings.TrimSuffix(txt, "\n"), "\n") { // fmt.Println("Testing line:", line) match, _ := regexp.MatchString(".*Your result on the battlefield:.*", line) if match { fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! REPORT SPOTTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") time.Sleep(1 * time.Second) ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, int64(user_botnestbot)) time.Sleep(1 * time.Second) ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, int64(user_chtwrscastlebot)) break } match, _ = regexp.MatchString(".*Leaderboard of fighters are updated: /top5 & /top6. ((Cheer up)|(Congratulations))!.*", line) if match { fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FIGHT SPOTTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") time.Sleep(1 * time.Second) ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, int64(user_chtwrscastlebot)) break } match, _ = regexp.MatchString("Deposited [βš‘πŸ“•πŸ“—πŸ“˜πŸ“™πŸ“’'a-zA-Z0-9+ ]* \\([0-9]*\\) successfully", line) if match { fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DEPOSIT SPOTTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") time.Sleep(1 * time.Second) ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, int64(chat_guild_deposit)) break } match, _ = regexp.MatchString("Received [βš‘πŸ“•πŸ“—πŸ“˜πŸ“™πŸ“’'a-zA-Z0-9+ ]* x [0-9]*", line) if match { fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! RECEPTION SPOTTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") time.Sleep(1 * time.Second) ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, int64(chat_guild_deposit)) break } } } } } } func ListenDarkwing(c *tdlib.Client) { eventFilter := func(msg *tdlib.TdMessage) bool { updateMsg := (*msg).(*tdlib.UpdateNewMessage) chatID := updateMsg.Message.ChatID senderUserID := updateMsg.Message.SenderUserID if senderUserID == user_botnestbot && chatID == chat_darkwing { return true } return false } receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100) for newMsg := range receiver.Chan { updateMsg := (newMsg).(*tdlib.UpdateNewMessage) senderUserID := updateMsg.Message.SenderUserID mType := updateMsg.Message.Content.GetMessageContentEnum() if mType == "messageText" { user, err := c.GetUser(senderUserID) if err != nil { fmt.Println("ListenDarkwing:", err.Error()) continue } txt := updateMsg.Message.Content.(*tdlib.MessageText).Text.Text fmt.Println("============== DARKWING (", user.Username, ") =================================================================") fmt.Println(txt, "\n") fmt.Println("===============================================================================================================") for _, line := range strings.Split(strings.TrimSuffix(txt, "\n"), "\n") { match, _ := regexp.MatchString(".*Your result on the battlefield:.*", line) if match { fmt.Println("!!!!!!!!!!!!!!!!! REPORT SPOTTED !!!!!!!!!!!!!!!!!") time.Sleep(1 * time.Second) ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, int64(user_botnestbot)) time.Sleep(1 * time.Second) ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, int64(user_chtwrscastlebot)) break } } } } } func ListenGuild(c *tdlib.Client) { eventFilter := func(msg *tdlib.TdMessage) bool { updateMsg := (*msg).(*tdlib.UpdateNewMessage) chatID := updateMsg.Message.ChatID // senderUserID := updateMsg.Message.SenderUserID if chatID == chat_guild { return true } return false } receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100) for newMsg := range receiver.Chan { updateMsg := (newMsg).(*tdlib.UpdateNewMessage) senderUserID := updateMsg.Message.SenderUserID mType := updateMsg.Message.Content.GetMessageContentEnum() if mType == "messageText" { user, err := c.GetUser(senderUserID) if err != nil { fmt.Println("ListenGuild:", err.Error()) continue } txt := updateMsg.Message.Content.(*tdlib.MessageText).Text.Text fmt.Println("============== GUILD (", user.Username, ") =================================================================") fmt.Println(txt, "\n") fmt.Println("===============================================================================================================") for _, line := range strings.Split(strings.TrimSuffix(txt, "\n"), "\n") { validID := regexp.MustCompile(`^/g_withdraw ([a-z0-9]+) ([0-9]+)$`) if validID.MatchString(line) && senderUserID != 121964035 { fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GUILD WITHDRAWAL SPOTTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") t := regexp.MustCompile(`/g_withdraw (?P[a-z0-9]+) (?P[0-9]+)`) if t.FindStringSubmatch(line) != nil { size, _ = strconv.Atoi(t.ReplaceAllString(line, "${Quantity}")) fmt.Printf("Withdrawing %s / %d\n", t.ReplaceAllString(line, "${Code}"), size) m := ChatWarsWithdraw{ Item: t.ReplaceAllString(line, "${Code}"), Quantity: int64(size), UserID64: int64(senderUserID), Time: time.Now(), } b, _ := json.Marshal(m) md5Bytes := md5.Sum(b) md5String := TgEncoding.EncodeToString(md5Bytes[:]) withdrawals[md5String] = m msgText = fmt.Sprintf("To validate @%s withdrawal of %d x %s\nClick /withdraw_%s\n", user.Username, size, items[t.ReplaceAllString(line, "${Code}")].Name, md5String) inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText(msgText, nil), true, true) c.SendMessage(chat_guild, 0, false, false, nil, inputMsgTxt) msgText = "" } else { fmt.Printf("Can't match withdrawing request.\n") } break } if validID.MatchString(line) && senderUserID == 121964035 { t := regexp.MustCompile(`/g_withdraw (?P[a-z0-9]+) (?P[0-9]+)`) if t.FindStringSubmatch(line) != nil { size, _ = strconv.Atoi(t.ReplaceAllString(line, "${Quantity}")) fmt.Printf("Withdrawing %s / %d\n", t.ReplaceAllString(line, "${Code}"), size) m := ChatWarsWithdraw{ Item: t.ReplaceAllString(line, "${Code}"), Quantity: int64(size), UserID64: int64(senderUserID), Time: time.Now(), } msgText = fmt.Sprintf("At your command Milord.\n") inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText(msgText, nil), true, true) c.SendMessage(chat_guild, 0, false, false, nil, inputMsgTxt) msgText = fmt.Sprintf("/g_withdraw %s %d\n", m.Item, m.Quantity) inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText(msgText, nil), true, true) msgMutex.Lock() sendMsg, _ := c.SendMessage(user_chtwrsbot, 0, false, false, nil, inputMsgTxt) msgID64 = sendMsg.ID msgText = string("/g_withdraw") msgUserID64 = m.UserID64 fmt.Println("send msgID64 (g_withdraw) : ", msgID64) } else { fmt.Printf("Can't match withdrawing request.\n") } break } validID = regexp.MustCompile(`^/withdraw_([ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]{26})$`) if validID.MatchString(line) { fmt.Println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GUILD WITHDRAW CONF SPOTTED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") u := regexp.MustCompile(`^/withdraw_(?P[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]{26})$`) if u.FindStringSubmatch(line) != nil { fmt.Printf("Withdrawal %s identified\n", u.ReplaceAllString(line, "${Reference}")) ref := u.ReplaceAllString(line, "${Reference}") if _, ok := withdrawals[ref]; ok { fmt.Printf("Withdrawal %s found\n", ref) t := time.Now() if t.Sub(withdrawals[ref].Time) > 300*time.Second { msgText = fmt.Sprintf("Reference %s is expired.\n", ref) inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText(msgText, nil), true, true) c.SendMessage(chat_guild, 0, false, false, nil, inputMsgTxt) msgText = "" } else { if withdrawals[ref].UserID64 != ownUserID64 && withdrawals[ref].UserID64 == int64(senderUserID) { inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText("You cannot validate your own withdrawal requests.\n", nil), true, true) c.SendMessage(chat_guild, 0, false, false, nil, inputMsgTxt) msgText = "" } else { msgText = fmt.Sprintf("/g_withdraw %s %d\n", withdrawals[ref].Item, withdrawals[ref].Quantity) inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText(msgText, nil), true, true) msgMutex.Lock() sendMsg, _ := c.SendMessage(user_chtwrsbot, 0, false, false, nil, inputMsgTxt) msgID64 = sendMsg.ID msgText = string("/g_withdraw") msgUserID64 = withdrawals[ref].UserID64 fmt.Println("send msgID64 (g_withdraw) : ", msgID64) delete(withdrawals, ref) } } } else { msgText = fmt.Sprintf("Reference %s is not found.\n", ref) inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText(msgText, nil), true, true) c.SendMessage(chat_guild, 0, false, false, nil, inputMsgTxt) msgText = "" } } else { msgText = fmt.Sprintf("Reference is malformed\n") inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText(msgText, nil), true, true) c.SendMessage(chat_guild, 0, false, false, nil, inputMsgTxt) msgText = "" } break } } } } } /* func ForwardOwnMsg(c *tdlib.Client) { eventFilter := func(msg *tdlib.TdMessage) bool { updateMsg := (*msg).(*tdlib.UpdateNewMessage) chatID := updateMsg.Message.ChatID senderUserID := updateMsg.Message.SenderUserID if (senderUserID == ownUserID32 && chatID != ownUserID64) { return true } return false } receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100) for newMsg := range receiver.Chan { updateMsg := (newMsg).(*tdlib.UpdateNewMessage) mType := updateMsg.Message.Content.GetMessageContentEnum() if mType == "messageText" { fwdMsg := ForwardMsg(c, updateMsg.Message.ID, updateMsg.Message.ChatID, ownUserID64) time.Sleep(2 * time.Second) DeleteMsg(c, fwdMsg) } } } */ func ListenAll(c *tdlib.Client) { eventFilter := func(msg *tdlib.TdMessage) bool { updateMsg := (*msg).(*tdlib.UpdateNewMessage) chatID := updateMsg.Message.ChatID // senderUserID := updateMsg.Message.SenderUserID if chatID == user_chtwrsbot || chatID == user_botnestbot || chatID == user_chtwrscastlebot || chatID == chat_darkwing || chatID == chat_guild { return false } return true } receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100) for newMsg := range receiver.Chan { updateMsg := (newMsg).(*tdlib.UpdateNewMessage) senderUserID := updateMsg.Message.SenderUserID mType := updateMsg.Message.Content.GetMessageContentEnum() if mType == "messageText" { username := "null" if senderUserID != 0 { user, err := c.GetUser(senderUserID) if err != nil { fmt.Println("Listen:", err.Error()) continue } else { username = user.Username } } t := time.Now() txt := updateMsg.Message.Content.(*tdlib.MessageText).Text.Text fmt.Printf("[%d-%02d-%02d %02d:%02d:%02d-00:00]", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()) fmt.Println(" === SENT (", username, ") =====================================================================") fmt.Println(txt, "\n") fmt.Println("************ DETAILS ************") fmt.Println("ID : ", updateMsg.Message.ID) fmt.Println("SenderUserID : ", updateMsg.Message.SenderUserID) fmt.Println("ChatID : ", updateMsg.Message.ChatID) fmt.Println("SendingState : ", updateMsg.Message.SendingState) fmt.Println("IsOutgoing : ", updateMsg.Message.IsOutgoing) fmt.Println("CanBeEdited : ", updateMsg.Message.CanBeEdited) fmt.Println("CanBeForwarded : ", updateMsg.Message.CanBeForwarded) fmt.Println("IsChannelPost : ", updateMsg.Message.IsChannelPost) fmt.Println("ContainsUnreadMention : ", updateMsg.Message.ContainsUnreadMention) fmt.Println("ForwardInfo : ", updateMsg.Message.ForwardInfo) fmt.Println("ReplyToMessageID : ", updateMsg.Message.ReplyToMessageID) fmt.Println("ViaBotUserID : ", updateMsg.Message.ViaBotUserID) fmt.Println("================================================================================================================") } } } func ForwardMsg(c *tdlib.Client, msgID int64, fromChatID int64, toChatID int64) int64 { msgIDs := make([]int64, 1) msgIDs[0] = msgID msgs, _ := c.ForwardMessages(toChatID, fromChatID, msgIDs, false, false, false) if msgs != nil { return msgs.Messages[0].ID } else { return 0 } } func DeleteMsg(c *tdlib.Client, chatID int64, msgID int64) { msgIDs := make([]int64, 1) msgIDs[0] = msgID c.DeleteMessages(chatID, msgIDs, false) fmt.Println("Deleting message ", msgID) } func OwnUserID(c *tdlib.Client) int32 { user, _ := c.GetMe() return user.ID }