Compare commits
No commits in common. "a2a352efe05c6c5bffde415df12260faa3eb9e2e" and "1f4f8003f216b157caed3f1778e07f63b1deb6ea" have entirely different histories.
a2a352efe0
...
1f4f8003f2
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rss-telegram-bot",
|
||||
"version": "2.0.0",
|
||||
"version": "1.0.8",
|
||||
"main": "lib/index.js",
|
||||
"author": "Fabian Stamm <dev@fabianstamm.de>",
|
||||
"license": "MIT",
|
||||
@ -42,4 +42,4 @@
|
||||
"typeorm": "^0.3.15"
|
||||
},
|
||||
"packageManager": "yarn@3.5.0"
|
||||
}
|
||||
}
|
||||
|
@ -41,15 +41,7 @@ function calculateHash(item: RSSFeedItem) {
|
||||
|
||||
async function checkFeed(feed: Feed) {
|
||||
Logging.info("Fetching feed: %s", feed.url);
|
||||
let timeoutSignal = new AbortController();
|
||||
let to = setTimeout(() => {
|
||||
Logging.warn("Feed %s fetch timed out", feed.url);
|
||||
timeoutSignal.abort();
|
||||
}, 10000);
|
||||
let data = await fetch(feed.url, {
|
||||
signal: timeoutSignal.signal
|
||||
}).then(res => res.text());
|
||||
clearTimeout(to);
|
||||
let data = await fetch(feed.url).then(res => res.text());
|
||||
Logging.info("Received Data");
|
||||
Logging.debug(data);
|
||||
|
||||
@ -117,14 +109,9 @@ export default async function checkFeeds() {
|
||||
continue;
|
||||
}
|
||||
|
||||
await checkFeed(feed);
|
||||
|
||||
feed.lastCheck = new Date();
|
||||
await AppDataSource.manager.save(feed);
|
||||
|
||||
Promise.resolve(async () => {
|
||||
await checkFeed(feed);
|
||||
}).catch(err => {
|
||||
Logging.warn("Error while checking feed: %s", feed.url);
|
||||
Logging.error(err);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
import { readFileSync } from "fs";
|
||||
import { AppDataSource, appDataSourceReady } from "./data_source.js";
|
||||
import { Feed } from "./models/Feed.js";
|
||||
import { Post } from "./models/Post.js";
|
||||
import { User } from "./models/User.js";
|
||||
|
||||
|
||||
|
||||
interface IOld {
|
||||
feeds: {
|
||||
url: string;
|
||||
oldEntries: string[];
|
||||
subscriber: number[];
|
||||
}[];
|
||||
}
|
||||
|
||||
|
||||
appDataSourceReady.then(async () => {
|
||||
let old = JSON.parse(readFileSync("./old.json", "utf-8")) as IOld;
|
||||
|
||||
for (let feed of old.feeds) {
|
||||
let f = await AppDataSource.manager.findOne(Feed, {
|
||||
where: {
|
||||
url: feed.url
|
||||
}
|
||||
})
|
||||
|
||||
if (!f) {
|
||||
f = AppDataSource.manager.create(Feed, {
|
||||
url: feed.url,
|
||||
lastCheck: new Date(0),
|
||||
oldEntries: [],
|
||||
subscriber: [],
|
||||
})
|
||||
|
||||
await AppDataSource.manager.save(f);
|
||||
}
|
||||
|
||||
for (let oldEntry of feed.oldEntries) {
|
||||
let existing = await AppDataSource.manager.findOne(Post, {
|
||||
where: {
|
||||
feed: f,
|
||||
hash: oldEntry
|
||||
}
|
||||
})
|
||||
if (!existing) {
|
||||
|
||||
let post = AppDataSource.manager.create(Post, {
|
||||
feed: f,
|
||||
hash: oldEntry
|
||||
})
|
||||
|
||||
await AppDataSource.manager.save(post);
|
||||
}
|
||||
}
|
||||
|
||||
for (let subscriber of feed.subscriber) {
|
||||
let user = await AppDataSource.manager.findOne(User, {
|
||||
where: {
|
||||
chatid: subscriber
|
||||
},
|
||||
relations: {
|
||||
feeds: true
|
||||
}
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
user = AppDataSource.manager.create(User, {
|
||||
chatid: subscriber,
|
||||
feeds: [f],
|
||||
})
|
||||
} else {
|
||||
user.feeds.push(f)
|
||||
}
|
||||
await AppDataSource.manager.save(user);
|
||||
}
|
||||
}
|
||||
})
|
@ -62,7 +62,8 @@ bot.command("delete", botHandler(async ctx => {
|
||||
}));
|
||||
|
||||
bot.on("callback_query", botHandler(async ctx => {
|
||||
Logging.info("Callback Query received");
|
||||
Logging.info("Callback Query:");
|
||||
Logging.info(ctx.callbackQuery);
|
||||
|
||||
const remove_options = () => {
|
||||
ctx.editMessageReplyMarkup({
|
||||
|
Loading…
Reference in New Issue
Block a user