How to use the telegraf/extra.HTML 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 ironsoul0 / headhunter / src / bot / scenes / askMessageForHunter.js View on Github external
const hunter = await User.findOne({
    // eslint-disable-next-line no-underscore-dangle
    target: user._id,
    killed: false,
  });

  const content = [
    "Your aim has left message for you šŸ˜",
    `<b>${message}</b>`,
  ].join("\n\n");

  try {
    ctx.telegram.sendMessage(
      hunter.chatId,
      content,
      Extra.HTML().markup(m =&gt;
        m.inlineKeyboard([m.callbackButton("Reply šŸ¤«", "Reply to Aim")])
      )
    );
  } catch (err) {
    console.log(err);
  }

  ctx.scene.leave();
  return ctx.reply(messageRecieved, ctx.mainMenu);
});
github ironsoul0 / headhunter / src / bot / scenes / askMessageForAim.js View on Github external
const user = await User.findOne({
    chatId,
  });

  const target = await User.findById(user.target);
  const content = [
    "Your hunter has left message for you šŸ˜®",
    `<b>${message}</b>`,
  ].join("\n\n");

  try {
    ctx.telegram.sendMessage(
      target.chatId,
      content,
      Extra.HTML().markup(m =&gt;
        m.inlineKeyboard([m.callbackButton("Reply šŸ¤«", "Reply to Hunter")])
      )
    );
  } catch (err) {
    console.log(err);
  }

  ctx.scene.leave();
  return ctx.reply(messageRecieved, ctx.mainMenu);
});
github LyoSU / LyAdminBot / handlers / message.js View on Github external
module.exports = async (ctx) => {
  if (ctx.chat.id > 0) {
    ctx.replyWithHTML(
      ctx.i18n.t('private.start', {
        name: userName(ctx.from)
      }),
      Extra.HTML().markup((m) => m.inlineKeyboard([
        m.urlButton(
          ctx.i18n.t('private.btn_add'),
          `https://t.me/${ctx.options.username}?startgroup=add`
        )
      ]))
    )
  } else {
    const lngDetector = new LanguageDetect()
    const detect = lngDetector.detect(ctx.message.text)

    if (detect.length > 0 && detect[0][1] > 0.3) {
      if (ctx.group.info.settings.removeLng.indexOf(detect[0][0]) >= 0) {
        ctx.deleteMessage()
      }
    }
  }
github telegraf / telegraf / docs / examples / keyboard-bot.js View on Github external
bot.command('inline', (ctx) =&gt; {
  return ctx.reply('<b>Coke</b> or <i>Pepsi?</i>', Extra.HTML().markup((m) =&gt;
    m.inlineKeyboard([
      m.callbackButton('Coke', 'Coke'),
      m.callbackButton('Pepsi', 'Pepsi')
    ])))
})
github ironsoul0 / headhunter / src / bot / commands / register.js View on Github external
bot.hears("šŸ¦ Become a Hunter", async ctx => {
    if (ctx.gameStarted) {
      ctx.reply("Registration is closed now šŸ˜­");
    } else {
      const chatId = ctx.update.message.from.id;
      const existingUser = await User.findOne({ chatId });

      if (existingUser) {
        ctx.reply("You are already a hunter šŸ˜‰");
        return;
      }

      ctx.reply(
        "Did you recieve a token from our website?",
        Extra.HTML().markup(m =>
          m.inlineKeyboard([
            m.callbackButton("Yes, let's go šŸŒŖ", "Token"),
            m.callbackButton("Not yet šŸŒ", "No token"),
          ])
        )
      );
    }
  });
github telegraf / telegraf / docs / examples / custom-router-bot.js View on Github external
const Telegraf = require('telegraf')
const Router = require('telegraf/router')
const Extra = require('telegraf/extra')
const session = require('telegraf/session')

const markup = Extra
  .HTML()
  .markup((m) => m.inlineKeyboard([
    m.callbackButton('Add 1', 'add:1'),
    m.callbackButton('Add 10', 'add:10'),
    m.callbackButton('Add 100', 'add:100'),
    m.callbackButton('Subtract 1', 'sub:1'),
    m.callbackButton('Subtract 10', 'sub:10'),
    m.callbackButton('Subtract 100', 'sub:100'),
    m.callbackButton('šŸˆ', Math.random().toString(36).slice(2)),
    m.callbackButton('Clear', 'clear')
  ], { columns: 3 }))

const calculator = new Router(({ callbackQuery }) => {
  if (!callbackQuery.data) {
    return
  }