From fc63c70df6693107e8da8c08baf476d6d598605c Mon Sep 17 00:00:00 2001 From: shoopea Date: Mon, 5 Oct 2020 11:37:37 +0200 Subject: [PATCH] update with bandrall --- main.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/main.go b/main.go index 7a02ea1..70e092a 100644 --- a/main.go +++ b/main.go @@ -472,6 +472,37 @@ func ListenGuild(c *tdlib.Client) { break + } + + if validID.MatchString(line) && senderUserID == 1378605 { + 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("Yes boss !\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) {