Compare commits
No commits in common. "791b601dec4fe7b344ade3b6d18f80edd9318f27" and "a2a352efe05c6c5bffde415df12260faa3eb9e2e" have entirely different histories.
791b601dec
...
a2a352efe0
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rss-telegram-bot",
|
||||
"version": "2.0.3",
|
||||
"version": "2.0.0",
|
||||
"main": "lib/index.js",
|
||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||
"license": "MIT",
|
||||
|
@ -98,12 +98,11 @@ async function checkFeed(feed: Feed) {
|
||||
// feed.addItems(newItems);
|
||||
}
|
||||
|
||||
const FEED_CHECK_INTERVAL = 1000 * 60 * 15;
|
||||
// const FEED_CHECK_INTERVAL = 1000 * 30;
|
||||
// const FEED_CHECK_INTERVAL = 1000 * 60 * 60;
|
||||
const FEED_CHECK_INTERVAL = 1000 * 30;
|
||||
|
||||
export default async function checkFeeds() {
|
||||
while (true) {
|
||||
Logging.info("Checking for feeds to synchronize");
|
||||
let feed = await AppDataSource.manager.findOne(Feed, {
|
||||
where: {
|
||||
lastCheck: LessThan(new Date(Date.now() - FEED_CHECK_INTERVAL))
|
||||
@ -114,14 +113,14 @@ export default async function checkFeeds() {
|
||||
})
|
||||
|
||||
if (!feed) {
|
||||
await new Promise(y => setTimeout(y, 10000));
|
||||
await new Promise(y => setTimeout(y, 1000));
|
||||
continue;
|
||||
}
|
||||
|
||||
feed.lastCheck = new Date();
|
||||
await AppDataSource.manager.save(feed);
|
||||
|
||||
Promise.resolve().then(async () => {
|
||||
Promise.resolve(async () => {
|
||||
await checkFeed(feed);
|
||||
}).catch(err => {
|
||||
Logging.warn("Error while checking feed: %s", feed.url);
|
||||
|
@ -64,35 +64,23 @@ bot.command("delete", botHandler(async ctx => {
|
||||
bot.on("callback_query", botHandler(async ctx => {
|
||||
Logging.info("Callback Query received");
|
||||
|
||||
const remove_options = (message: string) => {
|
||||
const remove_options = () => {
|
||||
ctx.editMessageReplyMarkup({
|
||||
inline_keyboard: [],
|
||||
inline_keyboard: []
|
||||
})
|
||||
ctx.editMessageText(message)
|
||||
}
|
||||
|
||||
let data = (ctx.callbackQuery as any).data;
|
||||
if (!data) {
|
||||
ctx.answerCbQuery("Invalid data");
|
||||
remove_options("Delete failed. Invalid data received.");
|
||||
remove_options();
|
||||
return
|
||||
}
|
||||
|
||||
let [action, id] = data.split(":");
|
||||
if (!action || !id) {
|
||||
ctx.answerCbQuery("Invalid data");
|
||||
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.");
|
||||
remove_options();
|
||||
return
|
||||
}
|
||||
|
||||
@ -112,12 +100,12 @@ bot.on("callback_query", botHandler(async ctx => {
|
||||
}
|
||||
} else {
|
||||
ctx.answerCbQuery("Invalid action");
|
||||
remove_options("Delete failed. Invalid data received.");
|
||||
remove_options();
|
||||
return
|
||||
}
|
||||
|
||||
ctx.answerCbQuery("Success");
|
||||
remove_options("Deleted feed: " + feed.url);
|
||||
remove_options();
|
||||
}));
|
||||
|
||||
bot.on(message("text", "entities"), botHandler(async ctx => {
|
||||
|
Loading…
Reference in New Issue
Block a user