How to use the telegraf.Extra.markup function in telegraf

To help you get started, we’ve selected a few telegraf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EdJoPaTo / telegraf-inline-menu / source / index.js View on Github external
const hitQuestionButton = async ctx => {
      const extra = Extra.markup(Markup.forceReply())
      await Promise.all([
        ctx.reply(questionText, extra),
        ctx.answerCbQuery(),
        ctx.deleteMessage()
          .catch(error => {
            if (/can't be deleted/.test(error)) {
              // Looks like message is to old to be deleted
              return
            }

            console.error('deleteMessage on question button failed', error)
          })
      ])
    }
github KrauseFx / FxLifeSheet / worker.ts View on Github external
function triggerNextQuestionFromQueue(ctx) {
  let keyboard = Extra.markup(m => m.removeKeyboard()); // default keyboard
  let questionAppendix = "";

  currentlyAskedQuestionObject = currentlyAskedQuestionQueue.shift();

  if (currentlyAskedQuestionObject == null) {
    ctx.reply("All done for now, let's do this 💪", keyboard);
    // Finished
    return;
  }

  if (currentlyAskedQuestionObject.question == null) {
    console.error("No text defined for");
    console.error(currentlyAskedQuestionObject);
  }

  if (currentlyAskedQuestionObject.type == "header") {
github KrauseFx / FxLifeSheet / worker.ts View on Github external
[getButtonText("0")]
    ];
    shuffleArray(allButtons);
    keyboard = Markup.keyboard(allButtons)
      .oneTime()
      .extra();
  } else if (currentlyAskedQuestionObject.type == "boolean") {
    keyboard = Markup.keyboard([["1: Yes"], ["0: No"]])
      .oneTime()
      .extra();
  } else if (currentlyAskedQuestionObject.type == "text") {
    // use the default keyboard we set here anyway
    questionAppendix +=
      "You can use a Bear note, and then paste the deep link to the note here";
  } else if (currentlyAskedQuestionObject.type == "location") {
    keyboard = Extra.markup(markup => {
      return markup.keyboard([
        markup.locationRequestButton("📡 Send location")
      ]);
    });
  }

  questionAppendix = currentlyAskedQuestionQueue.length + " more question";
  if (currentlyAskedQuestionQueue.length != 1) {
    questionAppendix += "s";
  }
  if (currentlyAskedQuestionQueue.length == 0) {
    questionAppendix = "last question";
  }

  let question =
    currentlyAskedQuestionObject.question + " (" + questionAppendix + ")";
github rjmunhoz / carbon-telegram-bot / src / util / keyboard.ts View on Github external
function getKeyboardExtra (url: string, refresh?: RefreshData) {
  return Extra.markup(() => getButtons(url, refresh))
}
github lomaster1 / youtube-subscription-watcher-telegram-bot / bot / settings.js View on Github external
selectLanguage(ctx, isStart) {
        const lang = ctx.state.userSettings.language;
        const message = L(lang, 'ASK_CHANGE_LANGUAGE');
        return ctx.reply(message, Extra.markup(
            Markup.inlineKeyboard([
                Markup.callbackButton('English', 'setlang|en|' + (isStart ? '1' : '0')),
                Markup.callbackButton('Русский', 'setlang|ru|' + (isStart ? '1' : '0'))
            ])
        ));
    },
    changeLanguage(ctx, language) {
github EdJoPaTo / telegraf-inline-menu / telegraf-inline-menu.js View on Github external
this.bot.action(actionCode, this.hideMiddleware(hide, ctx => {
      const extra = Extra.markup(Markup.forceReply())
      return Promise.all([
        ctx.reply(questionText, extra),
        ctx.deleteMessage()
      ])
    }))
github lomaster1 / youtube-subscription-watcher-telegram-bot / bot / reminder.js View on Github external
sendVideoUrl(userId, chatId, videoId, message, lang) {
        let msg = (message ? `${message} ` : '');
        msg += `https://www.youtube.com/watch?v=${videoId}`;
        return this._bot.telegrafApp.telegram.sendMessage(chatId, msg, Extra.markup(
            Markup.inlineKeyboard([
                Markup.callbackButton(L(lang, 'REMIND'), `remind|${videoId}`)
            ])
        ));
    },
    showRemindButton(ctx) {
github lomaster1 / youtube-subscription-watcher-telegram-bot / bot / reminder.js View on Github external
p = p.then(() => {
                            return ctx.reply(message, Extra.markup(
                                Markup.inlineKeyboard([
                                    Markup.callbackButton(L(lang, 'DO_NOT_REMIND_ME'), `removeRemind|${videoId}`)
                                ])
                            ))
                        })
                    });