# Announces new Trump posts via trumpstruth.org RSS
# Feed: https://www.trumpstruth.org/feed
# Detects ridiculous Trump-isms using pattern matching
feed_url "https://www.trumpstruth.org/feed"
poll_seconds 3600
curl "/usr/bin/curl"
curl_timeout 15
user_agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"
state_file "trumptruthrss.state"
max_chars 420
strip_non_ascii 1
exclude_retruths 1
max_new_announce 5
debug 0
min_findings 1
}
}
if {[info commands lreverse
] eq
""} {
}
}
if {$cfg(debug
)} { putlog "trumptruthrss: $msg" }
}
proc ::
trumptruthrss::
chan_enabled {chan
} {
putlog "trumptruthrss: channel flag enabletruth/enableTruth not defined"
}
proc ::
trumptruthrss::
enabled_channels {} {
}
}
proc ::
trumptruthrss::
load_state {} {
}
}
proc ::
trumptruthrss::
save_state {} {
}
}
proc ::
trumptruthrss::
is_retruth {item
} {
set clean
[string tolower
[::
trumptruthrss::
strip_html [dict get
$item text
]]]
}
proc ::
trumptruthrss::
curl_fetch {url
} {
set cmd
[list $cfg(curl
) -s -L --compressed -m
$cfg(curl_timeout
) \
-H "Accept: application/rss+xml, application/xml;q=0.9, */*;q=0.8" \
-H "User-Agent: $cfg(user_agent)" \
-w "\n__CURLMETA__:%{http_code}:%{content_type}\n" \
$url]
dlog "Fetching: $url"
putlog "trumptruthrss: curl failed: $err"
}
if {[regexp {__CURLMETA__:
(\d+
):
([^\r\n
]+
)} $out -
> code ctype
]} {
regsub {(\r
?\n
)?__CURLMETA__:
[0-
9]+:
[^\r\n
]+
(\r
?\n
)?$} $out "" body
dlog "HTTP $code (ctype=$ctype) bytes=[string length $body]"
}
proc ::
trumptruthrss::
html_decode {s
} {
"&" "&" "<" "<" ">" ">"
""" "\"" """ "\"" "'" "'"
"'" "'" " " " "
} $s]
}
proc ::
trumptruthrss::
strip_html {html
} {
regsub -all -nocase
{<br\s
*/
?>} $s "\n" s
regsub -all -nocase
{</p
>\s
*<p
>} $s "\n" s
set s
[::
trumptruthrss::
html_decode $s]
regsub -all
{[[:space:
]]+
} $s " " s
}
proc ::
trumptruthrss::
rss_gettag {block tag
} {
if {[string first
{<![CDATA
[} $val] ==
0} {
}
}
proc ::
trumptruthrss::
parse_feed {xml
} {
if {[string first
"<!doctype" $head] >=
0 ||
[string first
"<html" $head] >=
0} {
putlog "trumptruthrss: Got HTML instead of RSS/XML."; return {}
}
if {[string first
"<?xml" $head] < 0 && [string first
"<rss" $head] < 0 && \
[string first
"<feed" $head] < 0} {
putlog "trumptruthrss: Response doesn't look like RSS/XML."; return {}
}
}
set guid
[rss_gettag
$it "guid"]; set link [rss_gettag
$it "link"]
set title
[rss_gettag
$it "title"]; set desc
[rss_gettag
$it "description"]
set enc
[rss_gettag
$it "content:encoded"]; set pub [rss_gettag
$it "pubDate"]
set text
[expr {$enc ne
"" ? $enc :
($desc ne
"" ? $desc :
$title)}]
if {$guid eq
""} { set guid
[expr {$link ne
"" ? $link :
$title}] }
lappend out [dict create guid
$guid link $link text
$text pubDate
$pub]
}
}
# -----------------------------------------------------------------------
# THE RIDICULOUS-O-METER
# Each detector returns a short snarky string, or "" if not triggered.
# -----------------------------------------------------------------------
proc ::
trumptruthrss::
detect_caps {text
} {
# Count ALL-CAPS words (3+ letters, not abbreviations like USA/FBI we expect)
set words
[regexp -all -inline
{[A-Z
]{3,
}} $text]
# Filter out the common expected ones
set noise
{USA FBI CIA DOJ GOP DNC NBC ABC CBS CNN FOX GOP NATO GOP URL RSS
}
}
if {$n >=
4} { return "$n words needlessly screamed in caps" }
if {$n >=
2} { return "randomly screaming: [join [lrange $shouted 0 2] {, }]" }
}
proc ::
trumptruthrss::
detect_exclamations {text
} {
if {$n >=
5} { return "$n exclamation marks (calm down!!!)" }
if {$n >=
3} { return "$n exclamation marks used" }
}
proc ::
trumptruthrss::
detect_self_obsession {text
} {
# Count standalone first-person words using word boundaries
set count
[regexp -all
{\m
(i|me|my|myself|mine
)\M
} $lower]
if {$count >=
8} { return "refers to himself $count times in one post" }
if {$count >=
5} { return "$count first-person references (it's always about him)" }
}
proc ::
trumptruthrss::
detect_superlatives {text
} {
{the greatest} {the best ever} {the worst ever} {the biggest}
{the most beautiful} {the most powerful} {nobody has ever}
{the most successful} {better than anyone} {like nobody has seen}
{the best
in history} {the greatest ever
} {the most incredible
}
{the most popular} {number one} {like never before}
} {
}
if {[llength $found] >=
2} { return "stacked [llength $found] superlatives in one post" }
}
proc ::
trumptruthrss::
detect_conspiracy_words {text
} {
{witch hunt} {fake news} {rigged}
{hoax} {deep state} {enemy of the people}
{corrupt} {disgrace} {it was stolen}
{radical left} {they are destroying} {no other president}
{russia russia russia} {pedo} {human scum}
{very unfair} {many people are saying} {everybody knows}
{total disaster} {completely made up} {mainstream media}
{lamestream} {do nothing} {should be ashamed}
} {
}
if {[llength $hits] >=
3} { return "packed with [llength $hits] grievance buzzwords" }
if {[llength $hits] ==
1} { return "playing the '[lindex $hits 0]' card again" }
}
proc ::
trumptruthrss::
detect_nicknames {text
} {
{crooked} {sleepy} {crazy} {radical} {wacky}
{failing} {nasty} {slippery} {liddle} {pencil neck}
{low iq} {dumb} {dummy} {clown} {loser}
{weak} {corrupt} {cryin} {mini mike} {pocahontas}
{lyin} {shifty} {slimeball}
} {
}
if {[llength $names] >=
2} { return "name-calls [llength $names] people/things" }
}
proc ::
trumptruthrss::
detect_believe_me {text
} {
{believe me} {trust me} {everybody knows}
{many people are saying} {people are saying} {a lot of people think}
{everyone agrees} {nobody knows more} {i know more about}
{i alone can} {only i can} {nobody could have}
} {
}
if {[llength $phrases] >=
2} { return "asks you to just trust him [llength $phrases] times" }
if {[llength $phrases] ==
1} { return "\"[lindex $phrases 0]\" (citation needed)" }
}
proc ::
trumptruthrss::
detect_random_caps_nouns {text
} {
# Look for Title Case words mid-sentence that aren't after a period/! or a known proper noun
# Simple heuristic: capitalised word NOT at start of sentence and not all-caps
set words
[regexp -all -inline
{\s
[A-Z
][a-z
]{2,
}} $text]
set noise
{Trump Donald America American United States January Congress President Senate House
}
}
# Deduplicate
if {$n >=
5} { return "randomly capitalises $n nouns like a German textbook" }
if {$n >=
3} { return "mystery caps: [join [lrange $odd 0 2] {, }]..." }
}
proc ::
trumptruthrss::
detect_numbers {text
} {
# Suspiciously round or large numbers
{\d+ million people} {\d+ billion} {100 percent}
{100%} {millions and millions} {\d{2,} points}
{best numbers ever} {highest ever} {lowest ever}
} {
}
if {[llength $hits] >=
2} { return "throws out [llength $hits] suspiciously round statistics" }
if {[llength $hits] ==
1} { return "cites a very specific but unverifiable statistic" }
}
proc ::
trumptruthrss::
detect_threats {text
} {
{will be prosecuted
} {should be
in jail
} {lock
}
{will pay a big price} {i will} {very unfair}
{will be held accountable} {consequences} {price to pay}
{come after} {never forget} {be careful}
} {
}
if {[llength $found] >=
2} { return "vaguely threatens people [llength $found] times" }
if {[llength $found] ==
1} { return "issues ominous warning: '[lindex $found 0]'" }
}
# -----------------------------------------------------------------------
# Run all detectors, return list of findings (max 3 most interesting)
# -----------------------------------------------------------------------
proc ::
trumptruthrss::
analyse {text
} {
detect_conspiracy_words
detect_caps
detect_self_obsession
detect_nicknames
detect_superlatives
detect_believe_me
detect_exclamations
detect_random_caps_nouns
detect_numbers
detect_threats
} {
set result
[::
trumptruthrss::
$detector $text]
if {$result ne
""} { lappend findings
$result }
}
}
# -----------------------------------------------------------------------
# Convert an RFC 822 pubDate to Europe/London time (GMT or BST as appropriate).
# Falls back to the original string if Tcl can't parse it.
# -----------------------------------------------------------------------
proc ::
trumptruthrss::
is_bst {epoch
} {
# Returns 1 if the UTC epoch falls inside British Summer Time.
# BST runs from the last Sunday of March 01:00 UTC
# to the last Sunday of October 01:00 UTC.
# Last Sunday of March at 01:00 UTC
set bst_start
[expr {$mar31 -
$dow * 86400}]
# Last Sunday of October at 01:00 UTC
set bst_end
[expr {$oct31 -
$dow * 86400}]
return [expr {$epoch >=
$bst_start && $epoch < $bst_end}]
}
proc ::
trumptruthrss::
localise_date {pub} {
# Strip the trailing timezone offset (+0000 etc.) and parse as UTC.
# Uses -gmt 1 instead of -timezone for compatibility with older Tcl builds.
regsub {\s+
[+-
]\d
{4}\s
*$} $pub "" dateonly
if {[::
trumptruthrss::
is_bst $epoch]} {
}
} err]} {
putlog "trumptruthrss: localise_date failed for '$pub': $err"
}
}
# -----------------------------------------------------------------------
# Random eye-catching prefix for ridiculous posts
# -----------------------------------------------------------------------
proc ::
trumptruthrss::
random_prefix {} {
"Praise Allah!"
"Allahu Akbar!"
"Bismillah!"
"As the Quran foretold:"
"From the Mar-a-Lago mosque:"
"BREAKING: The orange one has spoken:"
"ALERT: Tiny hands on keyboard:"
"Oh no, he's at his phone again:"
"Covfefe alert:"
"Stand by for tremendous words:"
"The stable genius writes:"
"Fox News is on in the background:"
"3am Truth Social dispatch:"
"The golf cart has stopped:"
"Mar-a-Lago WiFi password: MAGA2024:"
"Someone take his phone:"
"The hamberder has been digested:"
"His lawyer is crying somewhere:"
"Historians will study this:"
"Hold onto your toupee:"
"The greatest post in history:"
"Unprompted and unhinged:"
"Nobody asked but here it is:"
"The world waits with bated breath:"
"Science cannot explain this:"
}
}
# -----------------------------------------------------------------------
# Format item. Returns "" if not ridiculous enough (skip it).
# force=1 bypasses the threshold (used by !truth command).
# -----------------------------------------------------------------------
proc ::
trumptruthrss::
format_item {item
{force
0}} {
set text
[::
trumptruthrss::
strip_html [dict get
$item text
]]
regsub -all
{[[:space:
]]+
} $text " " text
if {$cfg(strip_non_ascii
)} { regsub -all
{[^\x00-\x7F
]} $text "" text
}
set pub [::
trumptruthrss::
localise_date [dict get
$item pubDate
]]
# Skip posts with no readable text or that are just a URL
# Strip all URLs out and see if anything real is left
regsub -all
{https
?://
[^
[:space:
]]+
} $textonly "" textonly
}
set findings
[::
trumptruthrss::
analyse $text]
dlog "Findings for post: $findings"
if {!$force && [llength $findings] < $cfg(min_findings
)} {
dlog "Skipping post - only [llength $findings] findings"
}
# Build suffix: findings | date | link
}
}
if {$pub ne
""} { append suffix
" | $pub" }
if {$link ne
""} { append suffix
" | $link" }
# Keep the post snippet short and punchy (120 chars)
if {[string length
$text] > $snippet_limit} {
set text
"[string range $text 0 [expr {$snippet_limit - 4}]]..."
}
set prefix
"[::trumptruthrss::random_prefix] "
# Final safety trim to IRC limit
if {[string length
$text] > $available} {
set text
"[string range $text 0 [expr {$available - 4}]]..."
}
return "${prefix}$text$suffix"
}
proc ::
trumptruthrss::
announce_items {items
} {
set chans
[::
trumptruthrss::
enabled_channels]
set msg [::
trumptruthrss::
format_item $it]
}
}
proc ::
trumptruthrss::
schedule {} {
set timer_id
[utimer $cfg(poll_seconds
) ::
trumptruthrss::
poll]
}
proc ::
trumptruthrss::
poll {} {
::trumptruthrss::schedule
lassign [::trumptruthrss::curl_fetch $cfg(feed_url)] code ctype body
if {$code !=
200 ||
$body eq
""} {
putlog "trumptruthrss: fetch failed (HTTP=$code)"
}
set items
[::
trumptruthrss::
parse_feed $body]
if {[info exists cfg
(exclude_retruths
)] && $cfg(exclude_retruths
)} {
foreach it
$items { if {![::
trumptruthrss::
is_retruth $it]} { lappend filtered
$it } }
}
set last_guid
[dict get
[lindex $items 0] guid
]
::trumptruthrss::save_state
}
if {[dict get
$it guid
] eq
$last_guid} break
}
if {[llength $new] > $cfg(max_new_announce
)} {
}
::trumptruthrss::announce_items [lreverse $new]
set last_guid
[dict get
[lindex $items 0] guid
]
::trumptruthrss::save_state
}
proc ::
trumptruthrss::
cmd_latest {nick host
hand chan text
} {
if {![::
trumptruthrss::
chan_enabled $chan]} { return }
lassign [::trumptruthrss::curl_fetch $::trumptruthrss::cfg(feed_url)] code ctype body
if {$code !=
200 ||
$body eq
""} {
putserv "PRIVMSG $chan :Orange Truth: (error) couldn't fetch feed (HTTP=$code)."
}
set items
[::
trumptruthrss::
parse_feed $body]
putserv "PRIVMSG $chan :Orange Truth: (error) couldn't parse feed."
}
if {$msg eq
""} { set msg "Orange Truth: surprisingly restrained post, nothing to report." }
}
if {![::
trumptruthrss::
chan_enabled $chan]} { return }
lassign [::trumptruthrss::curl_fetch $::trumptruthrss::cfg(feed_url)] code ctype body
if {$code !=
200 ||
$body eq
""} {
putserv "PRIVMSG $chan :Orange Truth: (error) couldn't sync (HTTP=$code)."
}
set items
[::
trumptruthrss::
parse_feed $body]
putserv "PRIVMSG $chan :Orange Truth: (error) couldn't parse feed."
}
if {[dict get
$it guid
] eq
$last_guid} break
}
# Update state pointer without announcing anything
set last_guid
[dict get
[lindex $items 0] guid
]
::trumptruthrss::save_state
putserv "PRIVMSG $chan :Orange Truth: already up to date."
putserv "PRIVMSG $chan :Orange Truth: synced, skipped $n post[expr {$n == 1 ? {} : {s}}]. Use !truth to see the latest."
}
}
bind pub -
"!truth" ::
trumptruthrss::
cmd_latest
bind pub -
"!truthsync" ::
trumptruthrss::
cmd_sync
::trumptruthrss::load_state
::trumptruthrss::schedule
putlog "truthtrump.tcl loaded - Enable with: .chanset #chan +enabletruth"