ソースを参照

new prompt for tags generation, trim title and content

Pablo 1 週間 前
コミット
7054f227f7
2 ファイル変更12 行追加6 行削除
  1. 10 5
      src/portales/portal.ts
  2. 2 1
      src/utils/tag-generator.ts

+ 10 - 5
src/portales/portal.ts

@@ -74,6 +74,11 @@ export default class Portal {
           article.title = article.title.replace("Exclusivo suscriptor", "");
         }
 
+        article.title = article.title.replace(/\s+/g, " ").trim();
+        if (article.content !== "") {
+          article.content = article.content.replace(/\s+/g, " ").trim();
+        }
+
         let message = `${Emojis.NEWS} ${article.title}`;
         if (article.content !== "") {
           message += `\n\n${article.content}`;
@@ -89,20 +94,20 @@ export default class Portal {
           ? generatedTags
           : (this._scraperArticlesOptions.hashtags ?? []);
 
+        message += `\n${Emojis.LINK} ${article.link}`;
+
         if (tags.length > 0) {
-          message += `\n${Emojis.TAGS} ${tags.map((hashtag) => `#${hashtag}`).join(" ")}`;
+          message += `\n${tags.map((hashtag) => `#${hashtag}`).join(" ")}`;
         }
 
-        message += `\n${Emojis.LINK} ${article.link}`;
-
         // Mastodon allows a maximum of 500 characters, but historically this bot limits to 400
         if (message.length > 400) {
           const linkLine = `\n${Emojis.LINK} ${article.link}`;
           const tagsLine = tags.length > 0
-            ? `\n${Emojis.TAGS} ${tags.map((hashtag) => `#${hashtag}`).join(" ")}`
+            ? `\n${tags.map((hashtag) => `#${hashtag}`).join(" ")}`
             : "";
           const maxContentLength = 400 - linkLine.length - tagsLine.length;
-          message = `${Emojis.NEWS} ${article.title}\n\n${article.content.substring(0, Math.max(0, maxContentLength - 10))}...${tagsLine}${linkLine}`;
+          message = `${Emojis.NEWS} ${article.title}\n\n${article.content.substring(0, Math.max(0, maxContentLength - 10))}...${linkLine}${tagsLine}`;
         }
 
         if (this._name.toUpperCase() == "Chile Cultura".toUpperCase()) {

+ 2 - 1
src/utils/tag-generator.ts

@@ -23,7 +23,8 @@ export default class TagGenerator {
 
 Reglas:
 - Responde ÚNICAMENTE con un array JSON de strings.
-- Los hashtags deben estar en español.
+- En lo posible generar tags de una palabra.
+- Mantener el idioma original del contenido para generar los tags.
 - Sin espacios ni caracteres especiales dentro de cada hashtag.
 - Sin símbolo #.
 - Solo el array JSON, sin explicaciones.