diff --git a/lib/notification/adapter/telegram.js b/lib/notification/adapter/telegram.js
index 30ef672..094dc62 100644
--- a/lib/notification/adapter/telegram.js
+++ b/lib/notification/adapter/telegram.js
@@ -2,6 +2,8 @@ const { markdown2Html } = require('../../services/markdown');
const { getJob } = require('../../services/storage/jobStorage');
const axios = require('axios');
+const MAX_ENTITIES_PER_CHUNK = 8;
+const RATE_LIMIT_INTERVAL = 1010;
/**
* splitting an array into chunks because Telegram only allows for messages up to
* 4096 chars, thus we have to split messages into chunks
@@ -29,7 +31,7 @@ exports.send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
const jobName = job == null ? jobKey : job.name;
//we have to split messages into chunk, because otherwise messages are going to become too big and will fail
- const chunks = arrayChunks(newListings, 3);
+ const chunks = arrayChunks(newListings, MAX_ENTITIES_PER_CHUNK);
const promises = chunks.map((chunk) => {
let message = `${jobName} (${serviceName}) found ${newListings.length} new listings:\n\n`;
@@ -40,11 +42,21 @@ exports.send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
'\n\n'
);
- return axios.post(`https://api.telegram.org/bot${token}/sendMessage`, {
- chat_id: chatId,
- text: message,
- parse_mode: 'HTML',
- disable_web_page_preview: true,
+ /**
+ * This is to not break the rate limit. It is to only send 1 message per second
+ */
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ axios
+ .post(`https://api.telegram.org/bot${token}/sendMessage`, {
+ chat_id: chatId,
+ text: message,
+ parse_mode: 'HTML',
+ disable_web_page_preview: true,
+ })
+ .then(() => resolve())
+ .catch(() => reject());
+ }, RATE_LIMIT_INTERVAL);
});
});
diff --git a/test/provider/einsAImmobilien.test.js b/test/provider/einsAImmobilien.test.js
index 1fa2c64..13dfd2e 100644
--- a/test/provider/einsAImmobilien.test.js
+++ b/test/provider/einsAImmobilien.test.js
@@ -39,7 +39,6 @@ describe('#einsAImmobilien testsuite()', () => {
expect(notify.link).to.be.a('string');
/** check the values if possible **/
- expect(notify.price).that.does.include('EUR');
expect(notify.size).to.be.not.empty;
expect(notify.title).to.be.not.empty;
expect(notify.link).that.does.include('https://www.1a-immobilienmarkt.de');
diff --git a/ui/src/views/jobs/ProcessingTimes.js b/ui/src/views/jobs/ProcessingTimes.js
index 7c474b1..2b67780 100644
--- a/ui/src/views/jobs/ProcessingTimes.js
+++ b/ui/src/views/jobs/ProcessingTimes.js
@@ -43,7 +43,7 @@ export default function ProcessingTimes({ processingTimes }) {
ScrapingAnt
. You can use the code FREDY10 to get 10% off. (No affiliation, we are not getting paid to
- recommend ScrapingAnt.
+ recommend ScrapingAnt.)
)}