Skip to content

cb-wordpress-plugin

A call-baxter WordPress bridge plugin for rules that act on Telegram events.

Main actions: - wordpress.mirror_telegram_message - wordpress.flush_due_media_groups - wordpress.cleanup_orphan_media

Lower-level actions: - wordpress.create_post - wordpress.upload_media

The plugin is designed for rules like:

id: mirror-telegram-message-to-wordpress
enabled: true
match:
  source: telegram
  kind: telegram.message.new
actions:
  - kind: wordpress.mirror_telegram_message
    args:
      update: "{{ event.attrs.raw_update }}"
      required_hashtag: "#blog"

For Telegram media groups, the normal new-message mirror rule is also the staging path: - configure state_db_path and media_group_wait_seconds on the plugin; - route each telegram.message.new event through one wordpress.mirror_telegram_message action; - let the plugin buffer messages carrying media_group_id by chat_id + media_group_id; - flush due groups with wordpress.flush_due_media_groups; - create exactly one WordPress post from the assembled bundle.

Do not install a second broad new-message staging rule beside the mirror rule. Both would match the same update and invoke the action twice.

See docs/architecture.md, docs/cb-integration.md, and docs/e2e-telegram-webhook-to-wordpress.md for the responsibility split, rule shape, and complete Docker deployment path.

New in this build: - crash-recoverable idempotency state keyed by Telegram message ref and media-group key - deterministic WordPress slugs used to reconcile a remote post after a process crash - publication leases that suppress concurrent duplicate delivery across workers - duplicate deliveries are skipped once already mirrored or reconciled - Telegram edits update the existing WordPress post instead of creating a new one - hashtag-based post status routing (status_by_hashtag) - hashtag-based category routing (category_ids_by_hashtag) - WordPress tag syncing from hashtags (sync_tags_from_hashtags) - richer Telegram entity-aware HTML rendering for the mirrored body - a durable media-upload ledger with deterministic post reconciliation and safe cleanup of proven-unattached create media

Loading in call-baxter

Explicit module loading:

plugins:
  - module: cb_wordpress_plugin.plugin
    config:
      base_url: https://example.com
      username: wp-bot
      app_password: application-password-here
      state_db_path: ./state/wp-publications.db
      publication_lease_seconds: 30
      publication_wait_seconds: 2
      orphan_media_cleanup_after_seconds: 86400
      orphan_media_cleanup_limit: 50

state_db_path is required for crash recovery and cross-worker duplicate suppression. Without it, the plugin can still publish, but only WordPress's normal slug behavior protects against duplicate creates.

wordpress.flush_due_media_groups performs bounded orphan-media reconciliation using the configured age and limit. Operators can also invoke wordpress.cleanup_orphan_media directly, first with dry_run: true, to inspect or accelerate cleanup.

Entry-point discovery (after installing this package into the same environment as call-baxter):

discover_entry_points: true
entry_point_groups:
  - call_baxter.plugins
plugins:
  - call_baxter.plugins.system
  - call_baxter.plugins.telegram

When discovery is enabled, this package contributes the wordpress entry in call_baxter.plugins.

Operator helper CLI

The package installs cb-wp, a small WordPress REST helper that reuses the same environment variables as the Docker deployment. Prefer environment variables so the application password does not appear in shell history or the process list:

export WP_BASE_URL=https://example.com
export WP_USERNAME=wp-bot
export WP_APP_PASSWORD='xxxx xxxx xxxx xxxx xxxx xxxx'

# Verify that the application password authenticates successfully.
cb-wp verify

# Enumerate category term IDs and names for category_ids_by_hashtag / WP_CATEGORIES.
cb-wp categories
# 1 : Uncategorized
# 12 : News

cb-wp verify calls the authenticated wp/v2/users/me?context=edit endpoint. The helper never prints the configured application password. cb-wp categories walks category results in deterministic integer-ID order and prints exactly <int> : <string> per line.