Forum teuk.org

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

in Mediabot · started by TeuK · 4d ago

TeuK · 4d ago

Overview

The bot has been listening. After weeks of squashing bugs and hardening every corner of the codebase, Mediabot v3 receives its first major feature batch: seven new IRC commands, two Partyline tools, a birthday scheduler, and a memo-delivery system. All wired, tested, and production-ready.

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


📊 !stats [nick] — Personal Activity Stats

<teuk> m stats
<mediabot> teuk (Owner): 1247 messages (12.4% of #boulets) | last msg: 2026-05-11 15:22:01 | last seen: 2026-05-11 15:22:01 (PRIVMSG)

<teuk> m stats Boole
<mediabot> boole: 312 messages (3.1% of #boulets) | last msg: 2026-05-10 18:44:02

Queries CHANNEL_LOG for message count + percentage of channel traffic, USER_SEEN for last seen event, USER_LEVEL for registered level. Defaults to calling nick.


🏆 !top [n] — Most Active Users

<teuk> m top 5
<mediabot> Top 5 on #boulets:
<mediabot>   1. teuk             1247 msgs (12.4%)
<mediabot>   2. Poyan             844 msgs (8.4%)
<mediabot>   3. Boole             312 msgs (3.1%)

Ranks nicks by message count with percentage. Limit 1–10, default 5.


💬 !quote <nick> — Quote by Author

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

Fuzzy fallback: tries boole% first, then %boole% if nothing found. Uses LIMIT 1 OFFSET rand(count) — no ORDER BY RAND().


🧮 !calc <expression> — IRC Calculator

<teuk> m calc pi * 4
<mediabot> pi * 4 = 12.5663706143592

<teuk> m calc deg2rad(90)
<mediabot> deg2rad(90) = 1.5707963267949
  • Pre-substitution: pi, tau, e → literals before eval
  • Whitelist: digits, operators, sqrt/abs/floor/ceil/sin/cos/tan/atan2/round/deg2rad/rad2deg
  • Blacklist: system/exec/open/use/require/print/die/exit/eval/chr/ord
  • Hard limits: expression ≤ 128 chars, timeout 3s via alarm()

🎱 !8ball <question> — Magic 8-Ball

<teuk> m 8ball will it compile?
<mediabot> [8ball] teuk: Without a doubt.

20 classic answers, evenly split between positive, neutral, and negative.


📬 !remind <nick> <message> — IRC Memo

<teuk> m remind Poyan check the logs when you're back
<mediabot> -teuk- Reminder set for Poyan.

# ... later when Poyan speaks on the channel ...
<mediabot> Poyan: reminder from teuk (2026-05-11 15:44:31): check the logs when you're back

Stored in REMINDERS table, delivered automatically when the target nick sends any public message on the same channel. Hooked into on_message_PRIVMSG — fires on regular chat, not just commands. Up to 3 memos per message.

⚠️ Requires table creation:

CREATE TABLE IF NOT EXISTS REMINDERS (
    id_reminder INT AUTO_INCREMENT PRIMARY KEY,
    id_channel  INT NOT NULL,
    from_nick   VARCHAR(64) NOT NULL,
    to_nick     VARCHAR(64) NOT NULL,
    message     VARCHAR(512) NOT NULL,
    created_at  DATETIME DEFAULT NOW(),
    delivered   TINYINT DEFAULT 0,
    INDEX idx_deliver (id_channel, to_nick, delivered)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

🔮 Partyline .status — Runtime Session Dump

.status
--- runtime status (generated Mon May 11 15:35:00 2026) ---
Bot:      mediabotv3  uptime: 2h 14m 7s
Sessions: 2 active
  teuk              fd=11    level=Owner       console=off
  poyan             fd=12    level=Master      console=3
Channels: #boulets, #teuk, #radiocapsule
--- end ---

Bot nick via irc->nick_folded, uptime via metrics->{started}, sessions with level descriptions, joined channels via gethChannelsNicksOnChan.


📈 Partyline .metrics — Prometheus Snapshot

.metrics
--- Prometheus metrics ---
mediabot_commands_total 4721
mediabot_db_connected 1
--- end ---

Dumps current counters/gauges. HELP/TYPE metadata filtered out.


📋 Partyline .channels — Channel List

.channels
Channel              Status   Nicks  Owner
------------------------------------------------------------
#boulets             joined   23     Boole
#teuk                joined    3     teuk
#test                parted    0     none

Join status, live nick count, and owner — one batch SQL query for all channels.


🎂 Birthday Notifications — Daily Scheduler

* mediabotv3: Happy Birthday, Gwen! ❤️

Scheduler task birthday_check runs every 24h. Matches USER.birthday against today’s MM-DD (supports both MM-DD and YYYY-MM-DD formats). Posts on all auto-join channels.


🐛 Bugs Fixed Along the Way

Bug Fix
deliverReminders only fired on bot commands, not chat Moved hook to on_message_PRIVMSG
!remind called getIdChan() — doesn’t exist Inline SELECT id_channel FROM CHANNEL WHERE name = ?
New subs missing from @EXPORT Added mbStats_ctx, mbTop_ctx, mb8ball_ctx, mbRemind_ctx, deliverReminders, mbCalc_ctx, mbQuoteByNick, check_birthdays_today
.status showing Bot: ? uptime: ? level=0 Wired nick_folded, metrics->{started}, level_desc
.status channels block in wrong sub (_cmd_log) Moved to _cmd_status, $bot declared locally
.channels using is_member_of_channel() — doesn’t exist Replaced with gethChannelsNicksOnChan
!calc pi * 4 — bareword warning, result = 0 Pre-substitute pi/tau/e before eval
!calc closure warning on deg2rad/rad2deg Hardcoded constant instead of closing over $pi

📦 Files Changed

File Changes
UserCommands.pm mbStats_ctx (+%), mbTop_ctx (+%), mb8ball_ctx, mbRemind_ctx, deliverReminders
DBCommands.pm mbCalc_ctx — trig, constants pre-sub, alarm timeout
Quotes.pm mbQuoteByNick with fuzzy fallback
Partyline.pm _cmd_status, _cmd_metrics, _cmd_channels, dispatch, help
Hailo.pm check_birthdays_today
Mediabot.pm dispatch stats, top, calc, 8ball, remind, quote
mediabot.pl birthday_check Scheduler + deliverReminders in on_message_PRIVMSG

You must be logged in to reply.