From 5adc37b2db9910a129474e61c7f4c1673bd2e3d1 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 12 Mar 2023 11:45:09 +0100 Subject: [PATCH] Fix bug where the message might be too long --- src/Postbuilder.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Postbuilder.ts b/src/Postbuilder.ts index 179c5fe..91474d1 100644 --- a/src/Postbuilder.ts +++ b/src/Postbuilder.ts @@ -308,13 +308,13 @@ export class Postbuilder { } = await this.prepareImages(changesets) const imageUploader = new ImageUploader(randomImages, this._poster, this._globalConfig) - let timePeriod = "Yesterday" + let timePeriod = "yesterday" if (this._config.numberOfDays > 1) { - timePeriod = "In the past " + this._config.numberOfDays + " days" + timePeriod = "in the past " + this._config.numberOfDays + " days" } const singleTheme = this._config?.themeWhitelist?.length === 1 ? "/" + this._config.themeWhitelist[0] : "" let toSend: string[] = [ - `${timePeriod}, ${perContributor.keys().length} people made ${totalStats.total} changes to #OpenStreetMap using https://mapcomplete.osm.be${singleTheme}`, + `${perContributor.keys().length} people made ${totalStats.total} changes ${timePeriod} to #OpenStreetMap using https://mapcomplete.osm.be${singleTheme}`, "" ] @@ -344,7 +344,7 @@ export class Postbuilder { continue } const overview = await this.createOverviewForContributor(uid, changesetsMade) - if (overview.length + toSend.join("\n").length > 500) { + if (overview.length + toSend.join("\n").length + 1 /*+1 for the separating \n*/ > 500) { break } toSend.push(overview)