RSS bot: populate channel on first run so joiners see content
Previously the bot seeded all existing feed items on startup WITHOUT posting, so a freshly-created channel stayed empty and new subscribers saw nothing (only items appearing after start were posted). Now on first run it posts the latest items (max 5) to fill the channel — recent history then shows them to joiners — and sets an rss_populated flag so restarts don't replay. Existing (empty) bots get filled once on next start. Update rss_test.py. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -100,11 +100,12 @@ async def main() -> int:
|
||||
print("channel created:", bool(gid), "gid", gid)
|
||||
assert gid, "rss bot did not create a channel"
|
||||
|
||||
# 2) the first item was seeded, not posted
|
||||
await asyncio.sleep(2)
|
||||
texts = await channel_texts(b.chat, gid)
|
||||
assert not any("First post" in t for t in texts), "seeded item was wrongly broadcast"
|
||||
print("seed OK (first item not broadcast)")
|
||||
# 2) first run populates the channel with the existing item(s)
|
||||
got_initial = await wait_until(
|
||||
lambda: _contains(channel_texts(b.chat, gid), "First post"), timeout=20, every=2
|
||||
)
|
||||
print("initial item populated to channel:", bool(got_initial))
|
||||
assert got_initial, "channel was not populated on first run"
|
||||
|
||||
# 3) add a new item → it should be broadcast on the next poll
|
||||
FEED["items"].insert(0, ("Breaking news", "https://example.com/2"))
|
||||
|
||||
Reference in New Issue
Block a user