Forum teuk.org

🪧 Mediabot 3.4dev — The Enchanted Notice Board is now guarded on every path 🔐🪄

in Mediabot · started by TeuK · 4w ago

TeuK · 4w ago

Mediabot v3 continues its 3.4 development cycle with a focused extension of the external script bridge.

Scripts could already reply, send notices, write logs and arm timers. They can now also change the topic of their own channel through a new guarded topic action.

This is the first script action that writes persistent channel state, so it was designed with tighter rules than ordinary replies.

🪄 A fifth spell in the script protocol

A script can now return:

{"type":"topic","text":"New channel topic"}

The bridge then plans and applies a real IRC TOPIC command.

The action deliberately accepts no target field. The destination is always derived from the channel context that triggered the script. A script cannot ask to rewrite another channel’s topic, because that cross-channel variant simply does not exist.

In Hogwarts terms: the enchanted notice board may be rewritten, but only by a spell cast inside its own room.

🔐 Three locked gates

Changing a channel topic requires all three permissions:

ACTION_MODE=apply
ALLOW_IRC=yes
ALLOW_TOPIC=yes

ALLOW_TOPIC defaults to no.

Each refusal has its own explicit error, so the operator can see exactly which gate remained closed.

In dry-run mode, the action is validated and planned, but nothing is sent to IRC.

🧠 The Pensieve learns Reparo

The reference example topicreminder.pl now has two delivery modes.

Default mode:

CONFIG_topic=remind_after=900;mode=remind

The script waits, then posts a reminder containing the original topic and the nick that set it.

Restore mode:

CONFIG_topic=remind_after=900;mode=restore

The script waits, then restores the original topic through the new topic action.

The same script therefore demonstrates two useful ideas:

  • route configuration can select an action type;
  • delayed runs pass through the same security gates as immediate runs.

If ALLOW_TOPIC is still closed, the delayed restore fails cleanly, nothing is written to IRC, and the dedicated error remains visible in .scriptdryrun last.

⏳ The original memory stays intact

A delayed restore uses the topic captured when the timer was armed.

If someone changes the topic again before the callback fires, restore mode still brings back the original snapshot.

That behavior is intentional and documented. The Pensieve returns the memory it stored, not the latest version painted over it.

🛡️ Final wire-safety hardening

The final review found two important edge cases in the new action path.

First, topic text now receives the same UTF-8 wire encoding already used by reply and notice actions.

That prevents Unicode topics such as:

Welcome to the café 🪄

from reaching the asynchronous IRC writer as unsafe wide-character strings.

Second, channel context is canonicalized before the IRC command is sent.

A status-message form such as:

@#channel

is reduced to the real channel:

#channel

Malformed channel contexts are rejected before they can reach send_message.

🧪 Validation

The completed pass was validated with:

10785/10785 tests passed
Security audit: GO — all 11 invariants hold
Startup integrity: OK
41/41 modules loaded
83/83 cross-module methods resolved
197/197 dispatch handlers resolved

The checks cover topic action validation, the three permission gates, dry-run behavior, hot-reloadable ALLOW_TOPIC, delayed restore mode, closed-gate errors, channel-context canonicalization, malformed channel rejection and Unicode UTF-8 wire encoding.

No database schema change.
No mandatory live configuration change.
Topic writes remain disabled by default.

🧙 Summary

This round adds a powerful capability without loosening the bridge’s safety model:

  • scripts can change the topic of their own channel;
  • cross-channel targeting does not exist;
  • three independent gates control every write;
  • delayed restores obey the same rules;
  • Unicode reaches IRC safely;
  • decorated or malformed channel targets cannot slip through.

Mediabot’s enchanted notice board can now be rewritten and restored—but only after every lock, ward and protective charm agrees. 🪧🔐🪄

You must be logged in to reply.