mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-08-06 17:03:04 +02:00
readrss
thanks FJRP you can now return an rss feed
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# rss feed module for meshing-around 2025
|
||||
from modules.log import *
|
||||
import urllib.request
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
RSS_FEED_URL = rssFeedURL
|
||||
RSS_RETURN_COUNT = rssMaxItems
|
||||
RSS_TRIM_LENGTH = rssTruncate
|
||||
|
||||
def get_rss_feed():
|
||||
try:
|
||||
with urllib.request.urlopen(RSS_FEED_URL) as response:
|
||||
xml_data = response.read()
|
||||
root = ET.fromstring(xml_data)
|
||||
items = root.findall('.//item')[:RSS_RETURN_COUNT]
|
||||
if not items:
|
||||
return "No RSS feed entries found."
|
||||
formatted_entries = []
|
||||
for item in items:
|
||||
title = item.findtext('title', default='No title')
|
||||
link = item.findtext('link', default='No link')
|
||||
description = item.findtext('description', default='No description')
|
||||
pub_date = item.findtext('pubDate', default='No date')
|
||||
|
||||
# strip all HTML tags and markup
|
||||
description = ''.join(ET.fromstring(f"<div>{description}</div>").itertext())
|
||||
if len(description) > RSS_TRIM_LENGTH:
|
||||
description = description[:97] + "..."
|
||||
|
||||
formatted_entries.append(f"{title}\n{description}\n")
|
||||
return "\n".join(formatted_entries)
|
||||
except Exception as e:
|
||||
return f"Error fetching RSS feed: {e}"
|
||||
@@ -240,6 +240,10 @@ try:
|
||||
favoriteNodeList = config['general'].get('favoriteNodeList', '').split(',')
|
||||
enableEcho = config['general'].getboolean('enableEcho', False) # default False
|
||||
echoChannel = config['general'].getint('echoChannel', '9') # default 9, empty string to ignore
|
||||
rssEnable = config['general'].getboolean('rssEnable', True) # default True
|
||||
rssFeedURL = config['general'].get('rssFeedURL', 'http://www.hackaday.com/rss.xml')
|
||||
rssMaxItems = config['general'].getint('rssMaxItems', 3) # default 3 items
|
||||
rssTruncate = config['general'].getint('rssTruncate', 100) # default 100 characters
|
||||
|
||||
# emergency response
|
||||
emergency_responder_enabled = config['emergencyHandler'].getboolean('enabled', False)
|
||||
|
||||
@@ -210,6 +210,12 @@ if wikipedia_enabled:
|
||||
trap_list = trap_list + ("wiki:",)
|
||||
help_message = help_message + ", wiki:"
|
||||
|
||||
# RSS Feed Configuration
|
||||
if rssEnable:
|
||||
from modules.rss import * # from the spudgunman/meshing-around repo
|
||||
trap_list = trap_list + ("readrss",)
|
||||
help_message = help_message + ", readrss"
|
||||
|
||||
# LLM Configuration
|
||||
if llm_enabled:
|
||||
from modules.llm import * # from the spudgunman/meshing-around repo
|
||||
|
||||
Reference in New Issue
Block a user