Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 =>
m.inlineKeyboard([m.callbackButton("Reply š¤«", "Reply to Aim")])
)
);
} catch (err) {
console.log(err);
}
ctx.scene.leave();
return ctx.reply(messageRecieved, ctx.mainMenu);
});
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 =>
m.inlineKeyboard([m.callbackButton("Reply š¤«", "Reply to Hunter")])
)
);
} catch (err) {
console.log(err);
}
ctx.scene.leave();
return ctx.reply(messageRecieved, ctx.mainMenu);
});
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()
}
}
}
bot.command('inline', (ctx) => {
return ctx.reply('<b>Coke</b> or <i>Pepsi?</i>', Extra.HTML().markup((m) =>
m.inlineKeyboard([
m.callbackButton('Coke', 'Coke'),
m.callbackButton('Pepsi', 'Pepsi')
])))
})
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"),
])
)
);
}
});
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
}