"""announce.py: one message to every page at once, in Python. Run it by hand, from a deploy script or from cron: python announce.py "Maintenance tonight at 22:00" It never joins anything: one signed HTTP push to the public channel "announcements", which every page listens to. Python 3.10+. pip install -r requirements.txt (reads .env). Its key (dashboard, New API key): right publish, kind public, channels: exact name announcements. It can publish there and nowhere else, so the script is safe to hand out. """ import sys from datetime import datetime, timezone from pikoman_bot import PikomanError, Rest text = " ".join(sys.argv[1:]).strip() if not text: print('Usage: python announce.py "Maintenance tonight at 22:00"', file=sys.stderr) sys.exit(2) rest = Rest() # PIKOMAN_APP and PIKOMAN_API_KEY; PIKOMAN_HTTP only for another server try: # One request, signed for this request alone, reaches every page in the channel now. rest.publish("announcements", "notice", {"text": text, "at": datetime.now(timezone.utc).isoformat()}) print(f"Announced: {text}") except (PikomanError, OSError) as e: print("Not announced:", e, file=sys.stderr) # 403: the key may not publish to announcements sys.exit(1)