DarshanCode2005/telegram_noticeboard_bot

★ 0Forks 0PythonGitHub ↗Compare

README

Noticeboard Telegram Alerts

Free cron that checks Channel i Noticeboard every 10 minutes and sends you a Telegram message when a new latest notice appears.

Stack:

What the message contains

  • Heading
  • Direct notice link (https://channeli.in/noticeboard/notice/{id})
  • Category, uploader, created/modified time, expiry, important flag
  • Short plain-text summary from the notice body
  • Useful links found in the notice (forms, PDFs, etc.)

One-time Telegram setup

  1. Open @BotFather in Telegram.
  2. Send /newbot, choose a name and username, then copy the bot token.
  3. Open your new bot and press Start (or send it any message).
  4. Visit this URL in a browser, replacing <TOKEN>: https://api.telegram.org/bot<TOKEN>/getUpdates
  5. Find message.chat.id in the JSON response. That number is your chat ID.
  6. Keep both values private as GitHub Actions secrets.

Deploy on GitHub Actions (free)

  1. Create a public GitHub repository and push this project.
    • Scheduled workflows are free for public repos.
    • On free private repos, schedule triggers are typically disabled.
  2. In the repo: Settings → Secrets and variables → Actions, add:
    • TELEGRAM_BOT_TOKEN — token issued by BotFather
    • TELEGRAM_CHAT_ID — numeric message.chat.id from getUpdates
  3. Optional (only if Channel i starts requiring login for the API):
    • CHANNELI_COOKIES — full cookie header, or
    • CHANNELI_CSRFTOKEN + CHANNELI_SESSION
  4. Open Actions → Noticeboard Telegram Alert → Run workflow.
    • First try with dry_run = true to verify fetch/format.
    • Then run with defaults to send a real Telegram message.
  5. Leave the workflow enabled. Cron is */10 * * * * (every 10 minutes UTC).

GitHub may delay scheduled jobs by several minutes. That is expected.

Local usage

# Print the latest notice message without sending
python3 notice_alert.py --dry-run

# Send for real (requires env vars)
export TELEGRAM_BOT_TOKEN='123456789:your-token'
export TELEGRAM_CHAT_ID='123456789'
python3 notice_alert.py

# Resend current latest even if already notified
python3 notice_alert.py --force

State is stored in .notice_state.json (gitignored). On GitHub Actions the same file is restored/saved via the Actions cache so duplicates are skipped across runs.

Tests

python3 -m unittest discover -s tests -v

Duplicate behavior

  • First successful send stores the notice id.
  • Later runs skip Telegram if page-1 latest id is unchanged.
  • When a newer notice becomes the latest, a new message is sent.

Security notes

  • Never commit Telegram bot tokens, chat IDs in secret files, or Channel i session cookies.
  • Prefer a public repo with Actions secrets over putting credentials in code.
  • Revoke exposed Telegram tokens through BotFather and rotate exposed Channel i credentials.

Contributors

DarshanCode2005

Issues