Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.2 kB
1
Indexable
Never
amountObj = {amount: ''}
bot.on("text", (ctx) => {
     const text = ctx.message.text;
ctx.reply(
      Մուտքագրեք թվերը,
      Markup.inlineKeyboard([
        [
          { text: "C", callback_data: "C" },
          { text: "Remove", callback_data: "remove" },
        ],
        [
          { text: "7", callback_data: "7" },
          { text: "8", callback_data: "8" },
          { text: "9", callback_data: "9" },
        ],
        [
          { text: "4", callback_data: "4" },
          { text: "5", callback_data: "5" },
          { text: "6", callback_data: "6" },
        ],
        [
          { text: "1", callback_data: "1" },
          { text: "2", callback_data: "2" },
          { text: "3", callback_data: "3" },
        ],
        [
          { text: ",", callback_data: "." },
          { text: "0", callback_data: "0" },
          { text: "Send", callback_data: "send" },
        ],
      ])
    );
}

bot.on("callback_query", async (ctx) => {
const data = ctx.update.callback_query.data;
  if (data === "C") {
    amountObj.amount = "";
  } else if (data === "remove") {
    amountObj.amount = amountObj.amount.substring();
  } else {
    amountObj.amount += data;
  } );