package main

import (
	"io/ioutil"
	"log"
	"strings"

	tb "github.com/go-telegram-bot-api/telegram-bot-api"
)

var phoneNumbers = make(map[int64]string)
var phoneEditMsgIds = make(map[int64]string)

func PhoneKeyboard() tb.InlineKeyboardMarkup {
	return tb.NewInlineKeyboardMarkup(
		tb.NewInlineKeyboardRow(
			tb.NewInlineKeyboardButtonData("1", "1"),
			tb.NewInlineKeyboardButtonData("2", "2"),
			tb.NewInlineKeyboardButtonData("3", "3"),
		),
		tb.NewInlineKeyboardRow(
			tb.NewInlineKeyboardButtonData("4", "4"),
			tb.NewInlineKeyboardButtonData("5", "5"),
			tb.NewInlineKeyboardButtonData("6", "6"),
		),
		tb.NewInlineKeyboardRow(
			tb.NewInlineKeyboardButtonData("7", "7"),
			tb.NewInlineKeyboardButtonData("8", "8"),
			tb.NewInlineKeyboardButtonData("9", "9"),
		),
		tb.NewInlineKeyboardRow(
			tb.NewInlineKeyboardButtonData("📞", "call"),
			tb.NewInlineKeyboardButtonData("0", "0"),
			tb.NewInlineKeyboardButtonData("#", "clear"),
		),
	)

}

func main() {
	apiTokenBytes, err := ioutil.ReadFile("TOKEN")

	if err != nil {
		panic(err)
	}

	apiToken := strings.Trim(string(apiTokenBytes), " \t\n")

	bot, err := tb.NewBotAPI(apiToken)
	if err != nil {
		log.Panic(err)
	}

	bot.Debug = true

	log.Printf("Authorized on account %s", bot.Self.UserName)

	u := tb.NewUpdate(0)
	u.Timeout = 60

	updates, err := bot.GetUpdatesChan(u)

	if err != nil {
		panic(err)
	}

	for update := range updates {
		if update.CallbackQuery != nil {
			query := update.CallbackQuery

			log.Printf("%+v\n", update.CallbackQuery)
			log.Printf("message of callbackquery: %+v\n", update.CallbackQuery.Message.Chat)

			callbackQueryConfig := tb.CallbackConfig{
				CallbackQueryID: update.CallbackQuery.ID,
			}
			//update.CallbackQuery.Message.Chat ---> info about user
			userID := query.Message.Chat.ID

			if query.Data == "call" {
				if number, ok := phoneNumbers[userID]; ok {
					callbackQueryConfig.Text = number
				} else {
					callbackQueryConfig.Text = "NO NUMBER"
				}
			} else if query.Data == "clear" {
				delete(phoneNumbers, userID)
				updateNumberMsg := tb.NewEditMessageText(userID, query.Message.MessageID, "Введите номер")

				kbd := PhoneKeyboard()
				updateNumberMsg.ReplyMarkup = &kbd
				//updateKeyboardMsg := tb.NewEditMessageReplyMarkup(userID, query.Message.MessageID, PhoneKeyboard())
				bot.Send(updateNumberMsg)

			} else {
				if number, ok := phoneNumbers[userID]; ok {
					phoneNumbers[userID] = number + query.Data
				} else {
					phoneNumbers[userID] = query.Data
				}

				updateNumberMsg := tb.NewEditMessageText(userID, query.Message.MessageID, "Phone: "+phoneNumbers[userID])

				kbd := PhoneKeyboard()
				updateNumberMsg.ReplyMarkup = &kbd
				//updateKeyboardMsg := tb.NewEditMessageReplyMarkup(userID, query.Message.MessageID, PhoneKeyboard())
				bot.Send(updateNumberMsg)
				//bot.Send(updateKeyboardMsg)
			}

			bot.AnswerCallbackQuery(callbackQueryConfig)
			continue
		}

		if update.Message != nil {
			//log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)

			msg := tb.NewMessage(update.Message.Chat.ID, "Наберите номер")
			//msg.ReplyToMessageID = update.Message.MessageID
			msg.ReplyMarkup = PhoneKeyboard()
			bot.Send(msg)
			continue
		}

	}
}

Изменить пасту