Forum teuk.org

πŸ§™β€β™‚οΈ Mediabot v3 β€” The External Plugin Spellbook Gets Proper Wards

in Mediabot Β· started by TeuK Β· 1w ago

TeuK Β· 1w ago

Perl, Python and Tcl plugins are no longer a fragile side quest. They are becoming a real extension layer.

Over the last development passes, Mediabot v3 received a serious round of hardening around its external plugin system.

The goal was simple: make it safer and cleaner to let IRC commands call external scripts written in Perl, Python, or Tcl, without letting malformed configuration values, weird Perl references, broken JSON, or unsafe command tokens leak into the runtime.

In Hogwarts terms: the spellbook is still open, but the pages now have proper protective charms. πŸͺ„


✨ What users can do now

Mediabot can now be extended with small external scripts instead of putting every feature directly inside the main Perl bot.

That means you can start building lightweight command plugins such as:

  • a Perl helper for a quick IRC utility;
  • a Python command for API calls, data formatting, experiments, or automation;
  • a Tcl bridge for legacy Eggdrop/Windrop-style logic;
  • test commands like hello, pyhello, or tclhello to validate the whole chain;
  • safer dry-run / apply flows before enabling real actions in production.

The important part is that the plugin layer is no longer just β€œit works if everything is perfect”. It now has a stronger contract between Mediabot and external scripts.


πŸ§ͺ The practical plugin model

The current direction is intentionally simple:

  1. Mediabot receives an IRC command.
  2. The plugin layer normalizes the command name.
  3. Mediabot builds a clean JSON object.
  4. The external script receives that JSON object on STDIN.
  5. The script runs in Perl, Python, or Tcl.
  6. Mediabot reads the result and routes it back through the action layer.

So instead of hardcoding every new idea directly into the bot core, you can move small features into scripts and let Mediabot act as the guarded gateway.

That opens the door to cleaner experiments: new commands can be tested without turning the main bot into a giant cauldron of mixed responsibilities. πŸ§ͺ


πŸ›‘οΈ What was hardened in this series

This development series focused on contracts, guards, and predictable behavior.

1. Language and interpreter handling is stricter

The script runner now refuses malformed language values instead of accidentally accepting Perl references that stringify into strange values like ARRAY(...) or HASH(...).

This matters because language selection is security-sensitive: perl, python, and tcl must be real, deliberate values β€” not magical smoke from Perl internals.

2. Script directories and paths are cleaner

The constructor now protects script_dir handling. Invalid values fall back safely instead of being treated as usable paths.

That helps keep plugin discovery predictable and avoids surprising behavior when configuration values are malformed.

3. Command names are treated as real IRC tokens

A command name can no longer quietly contain spaces, control characters, newlines, or NUL bytes.

For example, malformed values like these are rejected:

hello world
hello\nworld
hello\rworld
hello\0world

This is important because the command name is used for routing. A command must be a clean token, not a cursed parchment with hidden characters in it. πŸ“œ

4. External scripts receive the canonical command

If a user types a command with extra spaces, prefixes, or uppercase letters, Mediabot normalizes it before sending it to the plugin.

So the external script receives the command Mediabot actually authorized and routed, not the raw noisy input.

That makes script behavior much easier to understand and debug.

5. JSON sent to scripts is now always an object

The external plugin bridge now insists on a clean JSON object envelope.

It rejects unsafe or invalid payload shapes such as:

[]
"hello"
42

A plugin should receive an object, not a random scalar or array. This gives plugin authors a stable shape to work with.

6. Plugin data is simplified before export

The data field sent to external scripts is now normalized.

Simple scalar values are preserved. Arrays of simple scalars are preserved. Arbitrary Perl references, nested objects, and overload tricks are removed or converted safely.

This prevents accidental leakage of Perl internals into external scripts.

7. Runtime limits and error handling are safer

Several runtime-related values now reject Perl references before numeric conversion. Top-level script errors are also checked as real scalar diagnostics.

That means fewer warnings, fewer weird overload surprises, and clearer failure messages.

The action layer now behaves less like a cursed mirror and more like a proper Ministry-approved dispatch desk. πŸ¦‰


πŸ§™ Why this matters for plugin authors

If you write a Mediabot plugin now, you can reason about the bridge more safely:

  • your script gets a JSON object on STDIN;
  • the command name is normalized before it reaches you;
  • malformed commands are rejected before execution;
  • language and interpreter values are guarded;
  • invalid runtime limits fall back safely;
  • broken internal payloads do not become weird JSON surprises;
  • Perl/Python/Tcl smoke tests validate the chain.

This is exactly the kind of boring reliability that makes fun features possible.

Nobody wants to debug a Python plugin only to discover the real problem was a Perl HASH(...) ghost sneaking through the wall. πŸ‘»


🧭 What this enables next

This hardening makes the next steps much more realistic:

  • documenting a clean plugin author guide;
  • adding more example scripts in Perl, Python, and Tcl;
  • making command routing easier to understand;
  • improving dry-run and apply workflows;
  • exposing safer plugin configuration examples;
  • eventually letting more Mediabot features live outside the core bot.

The big win is architectural: Mediabot can keep its Perl core stable while still allowing small, focused external commands to grow around it.

That is how a bot stops being a monolith and starts becoming a platform. 🏰


🧾 Summary for normal humans, not just wizards

Mediabot v3 can now call external plugins more safely.

Perl, Python, and Tcl scripts can be used as command helpers, with cleaner command normalization and stronger JSON contracts.

The recent work mostly hardened the bridge: less weird input, less Perl reference leakage, fewer unsafe edge cases, and more predictable behavior for plugin authors.

In short: the plugin system is becoming ready for real use, not just laboratory magic.

πŸͺ„ Mediabot v3 external plugins: safer commands, cleaner JSON, stronger runtime wards.

You must be logged in to reply.