Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async editRepos(ctx) {
const {subscriptions} = await this.db.getUser(getUser(ctx).id);
ctx.answerCallbackQuery('');
if (subscriptions && subscriptions.length) {
const row = (repo) => [
Markup.urlButton(`${repo.owner}/${repo.name}`, `https://github.com/${repo.owner}/${repo.name}`),
Markup.callbackButton('🗑️', `editRepos:delete:${repo.owner}/${repo.name}`)
];
return this.editMessageText(ctx,
'Your subscriptions',
Markup.inlineKeyboard([...subscriptions.map(row), [Markup.callbackButton('Back', `actionsList`)]]).extra()
);
} else {
this.editMessageText(ctx,
'You do not have a subscriptions',
keyboards.backToActions()
);
}
}
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) {
Markup.callbackButton(translation.t('deButton'), 'USER/LANGUAGE/DEUTSCH'),
Markup.callbackButton(translation.t('nlButton'), 'USER/LANGUAGE/DUTCH'),
Markup.callbackButton(translation.t('enButton'), 'USER/LANGUAGE/ENGLISH'),
Markup.callbackButton(translation.t('deButton'), 'USER/LANGUAGE/GERMAN'),
Markup.callbackButton(translation.t('ruButton'), 'USER/LANGUAGE/RUSSIAN'),
Markup.callbackButton(translation.t('frButton'), 'USER/LANGUAGE/FRENCH'),
Markup.callbackButton(translation.t('idButton'), 'USER/LANGUAGE/INDONESIAN'),
Markup.callbackButton(translation.t('jpButton'), 'USER/LANGUAGE/JAPANESE'),
Markup.callbackButton(translation.t('ptButton'), 'USER/LANGUAGE/PORTUGUESE'),
Markup.callbackButton(translation.t('esButton'), 'USER/LANGUAGE/SPANISH')
];
const back = [
Markup.callbackButton('<', 'USER/ALL')
];
return Markup.inlineKeyboard(languages.concat(back).map(line => [ line ]));
};
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) {
function getKeyboardObject (url: string, refresh?: RefreshData) {
const buttons = getButtons(url, refresh)
return Markup.inlineKeyboard(buttons as any)
}
async function buildKeyboard(buttons, actionCodePrefix, ctx) {
const resultButtons = await Promise.all(buttons.map(async row => {
if (typeof row === 'function') {
const rows = await row(ctx)
return Promise.all(rows.map(row => buildKeyboardRow(row, actionCodePrefix, ctx)))
}
return [await buildKeyboardRow(row, actionCodePrefix, ctx)]
}))
const resultButtonsFlatted = [].concat(...resultButtons)
return Markup.inlineKeyboard(resultButtonsFlatted)
}
export const confirmLocationKeyboard = (translation: I18n): InlineKeyboardMarkup => {
return Markup.inlineKeyboard([
Markup.callbackButton(translation.t('yesButton'), 'LOCATION/CONFIRM/YES'),
Markup.callbackButton(translation.t('noButton'), 'LOCATION/CONFIRM/NO')
]);
};
export const readlistMoreInfoKeyboard = (mangas: IListTitle[]): InlineKeyboardMarkup => {
const content = mangas.map((title: IListTitle) => [handleMediaButton({ kind: 'MANGA', title })]);
content.push([ Markup.callbackButton('<', 'MEDIA/READ/ALL') ]);
return Markup.inlineKeyboard(content);
};
export const dailyNotificationKeyboard = ({ language, translation }: IDailyNotificationKeyboard): InlineKeyboardMarkup => {
return Markup.inlineKeyboard([
Markup.callbackButton(translation.t(language, 'sourceButton'), 'SOURCE')
]);
};