Add .gitignore and fixed publish_digest.rb
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
config.env
|
||||||
|
*.csv
|
||||||
|
logs/
|
||||||
|
archive/
|
||||||
|
*.log
|
||||||
@@ -2,12 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Zprávobot.news - AI Daily Digest Publisher
|
# Zprávobot.news - AI Daily Digest Publisher
|
||||||
# Version: 1.0.1 (Cloudron - Direct HTTP)
|
# Version: 1.0.2 (Fixed URLs)
|
||||||
#
|
|
||||||
# Generates and publishes daily digest posts to Mastodon bots:
|
|
||||||
# - @zpravobot (7:30) - neutral overview
|
|
||||||
# - @pozitivni (12:00) - positive news
|
|
||||||
# - @sarkasticky (19:00) - sarcastic commentary
|
|
||||||
|
|
||||||
require 'csv'
|
require 'csv'
|
||||||
require 'json'
|
require 'json'
|
||||||
@@ -376,25 +371,26 @@ def generate_links_toot(topics, style)
|
|||||||
posts = topics[topic]
|
posts = topics[topic]
|
||||||
links << "\n#{topic}:"
|
links << "\n#{topic}:"
|
||||||
|
|
||||||
|
# Select diverse posts (first and middle)
|
||||||
selected = []
|
selected = []
|
||||||
selected << posts[0] if posts[0]
|
selected << posts[0] if posts[0]
|
||||||
selected << posts[posts.size / 2] if posts.size > 1
|
selected << posts[posts.size / 2] if posts.size > 1
|
||||||
|
|
||||||
selected[0...max_links_per_topic].each do |post|
|
selected[0...max_links_per_topic].each do |post|
|
||||||
|
# Extract title (first line, max 50 chars)
|
||||||
title = post['text'].split("\n")[0][0..50].strip
|
title = post['text'].split("\n")[0][0..50].strip
|
||||||
title = title.gsub(/\s+/, ' ')
|
title = title.gsub(/\s+/, ' ')
|
||||||
|
|
||||||
url = post['extracted_url']
|
url = post['extracted_url']
|
||||||
next unless url && !url.empty?
|
next unless url && !url.empty?
|
||||||
|
|
||||||
short_url = url.gsub(/https?:\/\//, '')
|
# Use full URL (Mastodon counts it as 23 chars anyway)
|
||||||
short_url = short_url[0..37] + '...' if short_url.length > 40
|
|
||||||
|
|
||||||
links << "• #{title}..."
|
links << "• #{title}..."
|
||||||
links << " 🔗 #{short_url}"
|
links << " #{url}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Style-specific header and footer
|
||||||
case style
|
case style
|
||||||
when 'neutral'
|
when 'neutral'
|
||||||
header = "📌 VYBRANÉ ČLÁNKY DNE:"
|
header = "📌 VYBRANÉ ČLÁNKY DNE:"
|
||||||
@@ -411,7 +407,9 @@ def generate_links_toot(topics, style)
|
|||||||
|
|
||||||
toot = header + links.join("\n") + footer
|
toot = header + links.join("\n") + footer
|
||||||
|
|
||||||
|
# Ensure under 500 chars
|
||||||
if toot.length > 500
|
if toot.length > 500
|
||||||
|
# Truncate links section
|
||||||
truncated_links = links[0..(links.size * 2 / 3)]
|
truncated_links = links[0..(links.size * 2 / 3)]
|
||||||
toot = header + truncated_links.join("\n") + footer
|
toot = header + truncated_links.join("\n") + footer
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user