Pārlūkot izejas kodu

Merge branch 'develop' of Mastodon/bots into main

Pablo Yaksic 2 nedēļas atpakaļ
vecāks
revīzija
d59814e9ec

+ 3 - 1
.env.example

@@ -14,6 +14,7 @@ MASTODON_DB_PASSWORD = "password"
 MASTODON_DB_DATABASE = "mastodon"
 
 # PORTALES
+ADNRADIO = "https://www.adnradio.cl/"
 BIOBIOCHILE = "https://www.biobiochile.cl/"
 CHILECULTURA = "https://chilecultura.gob.cl/events/"
 CIPER = "https://www.ciperchile.cl/actualidad/"
@@ -34,7 +35,8 @@ TARREO = "https://www.tarreo.com/noticias/"
 THECLINIC = "https://www.theclinic.cl/lo-ultimo/"
 
 # KEYS
-MASTODON_KET_BIOBIOCHILE = ""
+MASTODON_KEY_ADNRADIO = ""
+MASTODON_KEY_BIOBIOCHILE = ""
 MASTODON_KEY_CHILECULTURA = ""
 MASTODON_KEY_CIPER = ""
 MASTODON_KEY_CODEXVERDE = ""

+ 1 - 0
serverless.yml

@@ -20,5 +20,6 @@ functions:
   - ${file(./src/portales/interferencia/definition.yml)}
   - ${file(./src/portales/emol/definition.yml)}
   - ${file(./src/portales/latercera/definition.yml)}
+  - ${file(./src/portales/adnradio/definition.yml)}
   - ${file(./src/portales/theclinic/definition.yml)}
   - ${file(./src/agents/countdown/definition.yml)}

+ 2 - 0
src/config.ts

@@ -15,6 +15,7 @@ const config = {
   MASTODON_DB_PASSWORD: process.env.MASTODON_DB_PASSWORD,
   MASTODON_DB_DATABASE: process.env.MASTODON_DB_DATABASE,
   // PORTALES
+  ADNRADIO: process.env.ADNRADIO ?? "https://www.adnradio.cl/",
   BIOBIOCHILE: process.env.BIOBIOCHILE ?? "https://www.biobiochile.cl/",
   CHILECULTURA: process.env.CHILECULTURA ?? "https://chilecultura.gob.cl/",
   CIPER: process.env.CIPER ?? "https://www.ciperchile.cl/actualidad/",
@@ -35,6 +36,7 @@ const config = {
   TARREO: process.env.TARREO ?? "https://www.tarreo.com/noticias/",
   THECLINIC: process.env.THECLINIC ?? "https://www.theclinic.cl/lo-ultimo/",
   // KEYS
+  MASTODON_KEY_ADNRADIO: process.env.MASTODON_KEY_ADNRADIO ?? "",
   MASTODON_KEY_BIOBIOCHILE: process.env.MASTODON_KEY_BIOBIOCHILE ?? "",
   MASTODON_KEY_CHILECULTURA: process.env.MASTODON_KEY_CHILECULTURA ?? "",
   MASTODON_KEY_CIPER: process.env.MASTODON_KEY_CIPER ?? "",

+ 2 - 0
src/index.ts

@@ -2,6 +2,7 @@ import { type Context, type Handler } from "aws-lambda";
 
 import config from "./config";
 
+import { handler as adnradio } from "./portales/adnradio/handler";
 import { handler as biobiochile } from "./portales/biobiochile/handler";
 import { handler as chilecultura } from "./portales/chilecultura/handler";
 import { handler as ciper } from "./portales/ciper/handler";
@@ -38,6 +39,7 @@ const context: Context = {
 };
 
 const portalsHandlers = {
+  "adnradio": adnradio,
   "biobiochile": biobiochile,
   "chilecultura": chilecultura,
   "ciper": ciper,

+ 4 - 0
src/portales/adnradio/definition.yml

@@ -0,0 +1,4 @@
+adnradio:
+  handler: ./src/portales/adnradio/handler.handler
+  events:
+    - schedule: rate(1 hour)

+ 25 - 0
src/portales/adnradio/handler.ts

@@ -0,0 +1,25 @@
+import { type Handler } from "aws-lambda";
+
+import config from "../../config";
+import Portal from "../portal";
+import ScraperMethods from "../../enums/scraper-methods";
+
+const name = "ADN Radio";
+
+export const handler: Handler = new Portal(
+  name,
+  config.MASTODON_KEY_ADNRADIO,
+  {
+    url: config.ADNRADIO,
+    articlesSelector: "article.sc",
+    titleSelector: "h3 a",
+    linkSelector: "h3 a",
+    contentSelector: "p.ent",
+    imageSelector: "figure img",
+    linkPrefix: "https://www.adnradio.cl",
+    scraperMethod: ScraperMethods.AXIOS,
+    cacheExpiration: 60 * 60 * 24 * 5, // 5 días
+    maxArticles: 20,
+    hashtags: ["ADNRadio", "Chile", "Noticias"]
+  }
+).getHandler();