Add small UX improvements
All checks were successful
continuous-integration/drone/tag Build is passing
All checks were successful
continuous-integration/drone/tag Build is passing
This commit is contained in:
parent
a2a352efe0
commit
96d457ab11
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rss-telegram-bot",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"main": "lib/index.js",
|
||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||
"license": "MIT",
|
||||
|
@ -64,23 +64,35 @@ bot.command("delete", botHandler(async ctx => {
|
||||
bot.on("callback_query", botHandler(async ctx => {
|
||||
Logging.info("Callback Query received");
|
||||
|
||||
const remove_options = () => {
|
||||
const remove_options = (message: string) => {
|
||||
ctx.editMessageReplyMarkup({
|
||||
inline_keyboard: []
|
||||
inline_keyboard: [],
|
||||
})
|
||||
ctx.editMessageText(message)
|
||||
}
|
||||
|
||||
let data = (ctx.callbackQuery as any).data;
|
||||
if (!data) {
|
||||
ctx.answerCbQuery("Invalid data");
|
||||
remove_options();
|
||||
remove_options("Delete failed. Invalid data received.");
|
||||
return
|
||||
}
|
||||
|
||||
let [action, id] = data.split(":");
|
||||
if (!action || !id) {
|
||||
ctx.answerCbQuery("Invalid data");
|
||||
remove_options();
|
||||
remove_options("Delete failed. Invalid data received.");
|
||||
return
|
||||
}
|
||||
let feed = await AppDataSource.manager.findOne(Feed, {
|
||||
where: {
|
||||
id: Number(id)
|
||||
}
|
||||
});
|
||||
|
||||
if (!feed) {
|
||||
ctx.answerCbQuery("Invalid action");
|
||||
remove_options("Delete failed. Feed not available.");
|
||||
return
|
||||
}
|
||||
|
||||
@ -100,12 +112,12 @@ bot.on("callback_query", botHandler(async ctx => {
|
||||
}
|
||||
} else {
|
||||
ctx.answerCbQuery("Invalid action");
|
||||
remove_options();
|
||||
remove_options("Delete failed. Invalid data received.");
|
||||
return
|
||||
}
|
||||
|
||||
ctx.answerCbQuery("Success");
|
||||
remove_options();
|
||||
remove_options("Deleted feed: " + feed.url);
|
||||
}));
|
||||
|
||||
bot.on(message("text", "entities"), botHandler(async ctx => {
|
||||
|
Loading…
Reference in New Issue
Block a user