Forum teuk.org

🧙 Accio Features! — New Spells for Mediabot v3 (May 2026)

in Mediabot · started by TeuK · 5d ago

TeuK · 5d ago

Overview

The sorting hat has spoken: it’s time for new functionality. After weeks of deep auditing and bug-squashing, Mediabot v3 receives its first major feature batch. Seven new spells were cast across six modules — all production-ready, all wired to the Scheduler, the Partyline, and the IRC dispatch table.

The Dark Lord of missing commands has been vanquished. 🪄


✨ New IRC Commands

📊 !stats [nick] — Personal Activity Stats

<teuk> !stats
<mediabot> teuk (Master): 1247 messages on #boulets | last msg: 2026-05-10 09:12:31 | last seen: 2026-05-10 09:12:31 (PRIVMSG)

<teuk> !stats Boole
<mediabot> boole: 312 messages on #boulets | last msg: 2026-05-09 18:44:02 | last seen: 2026-05-09 18:44:02 (QUIT)

Shows message count from CHANNEL_LOG, last seen event from USER_SEEN, and registered user level if applicable. Defaults to the calling nick when no argument is provided.


🏆 !top [n] — Most Active Users

<teuk> !top 5
<mediabot> Top 5 on #boulets:
<mediabot>   1. teuk             1247 msgs
<mediabot>   2. Poyan             844 msgs
<mediabot>   3. Boole             312 msgs
<mediabot>   4. Menz              201 msgs
<mediabot>   5. Gwen               87 msgs

Ranks the most active nicks by message count on the current channel. Limit 1–10, default 5. Pure COUNT(*) GROUP BY nick ORDER BY DESC on CHANNEL_LOG.


💬 !quote <nick> — Quote by Author

<teuk> !quote Boole
<mediabot> [42] <Boole> si Linux était une pizza, la croûte ce serait le kernel

Extends the existing !q command with per-author filtering. Uses LIMIT 1 OFFSET rand(count) — no ORDER BY RAND(), consistent with the rest of the quote system.


🧮 !calc <expression> — IRC Calculator

<teuk> !calc (12 * 4) + sqrt(16)
<mediabot> (12 * 4) + sqrt(16) = 52

<teuk> !calc pi * 6^2
<mediabot> pi * 6^2 = 113.097335529232

Evaluates arithmetic expressions safely:

  • Whitelist: digits, operators + - * / ** % ^ ( ) ., named functions (sqrt, floor, ceil, abs, log, exp), constants pi, e
  • Blacklist: system, exec, open, use, require, print, die, exit, eval, chr, ord, sprintf
  • Hard limit: expression ≤ 128 chars, evaluation timeout 3 seconds via alarm()
  • Formats result as integer when whole, scientific notation otherwise

🔮 Partyline New Commands

📡 .status — Runtime Session Dump

.status
--- runtime status (generated Fri May 10 09:15:00 2026) ---
Bot:      mediabotv3  uptime: 2d 4h 17m
Sessions: 2 active
  teuk              fd=11    level=Owner     console=3
  poyan             fd=12    level=Master    console=off
--- end ---

Reads _runtime_status_payload — the same data written atomically to the JSON status file — and formats it for the telnet/DCC session. No extra DB call, pure in-memory read.


📈 .metrics — Prometheus Metrics Dump

.metrics
--- Prometheus metrics ---
mediabot_commands_total 4721
mediabot_auth_sessions_total 2
mediabot_partyline_logins_total 14
mediabot_db_connected 1
mediabot_channels_managed 3
--- end ---

Dumps the current Prometheus gauge/counter values directly in the Partyline session. HELP and TYPE metadata lines are filtered out for readability. No need to open a browser to check what the bot is doing.


🎂 Birthday Notifications — Scheduler Task

A new daily Scheduler task birthday_check runs at bot startup and every 24 hours. It queries USER.birthday for entries matching today’s MM-DD, and posts a greeting on every auto-join channel:

* mediabot: Happy Birthday, Gwen! ❤️

Supports both MM-DD and YYYY-MM-DD stored formats. If the bot starts mid-day, birthdays for that day are still caught.


💡 Notes

  • !weather cache — already implemented in a previous session (TTL 3 min fresh + 15 min stale). No action needed.
  • All new IRC commands are wired into mbCommandPublic and mbCommandPrivate dispatch.
  • !calc runs synchronously but is protected by a 3-second alarm() in the child eval — a tight expression won’t freeze the bot.
  • Birthday notifications use Helpers::botPrivmsg with a red-bold heart \x034\x02<3\x0f for a bit of flair. 🎉

📦 Files Changed

Module Changes
UserCommands.pm mbStats_ctx, mbTop_ctx
DBCommands.pm mbCalc_ctx
Quotes.pm mbQuoteByNick
Partyline.pm _cmd_status, _cmd_metrics + dispatch + help
Hailo.pm check_birthdays_today
Mediabot.pm dispatch entries for stats, top, calc, quote
mediabot.pl birthday_check Scheduler task

“Accio Features! Seven new spells materialised from the ether — each tested, each wired, each ready for the Great Hall.” 🏰✨

You must be logged in to reply.