Forum teuk.org

๐Ÿช„ Finite Incantatem! โ€” Mediabot v3 Feature Wave II (May 2026)

in Mediabot ยท started by TeuK ยท 4d ago

TeuK ยท 4d ago

Overview

Nine new spells โ€” and five bugs banished along the way. The second feature wave brings reminder management, activity analytics, IRC classics, and Partyline power tools. Every command tested in production, every bug squashed before it could multiply.

โ€œFinite Incantatem! The chaos is contained. The features stand.โ€ โœจ


๐Ÿ“ฌ Reminder Management โ€” !remindlist & !remind cancel <id>

<teuk> m remindlist
<mediabot> -teuk- 2 pending reminder(s):
<mediabot> -teuk-   #4 -> Poyan: "check the logs" (2026-05-11 15:44)
<mediabot> -teuk-   #5 -> Boole: "review the PR"  (2026-05-11 16:02)

<teuk> m remind cancel 4
<mediabot> -teuk- Reminder #4 cancelled.

!remindlist shows all undelivered reminders sent by the calling nick on the current channel. !remind cancel <id> marks a reminder as cancelled (delivered=2) โ€” it will never be delivered. Both are scoped to the channel.


๐Ÿ“Š !stats โ€” First Seen Added

<teuk> m stats Boole
<mediabot> boole: 312 messages (3.1% of #boulets) | first seen: 2024-01-15 09:12:01 | last msg: 2026-05-10 18:44:02 | last seen: 2026-05-10 18:44:02 (QUIT)

MIN(ts) added to the CHANNEL_LOG query โ€” the first time a nick was ever seen posting on the channel.


๐Ÿ† !top โ€” Period Filter

<teuk> m top 5 30d
<mediabot> Top 5 on #boulets (last 30d):
<mediabot>   1. teuk    412 msgs (18.3%)
<mediabot>   2. Poyan   201 msgs (8.9%)
...

<teuk> m top 3 7d
<teuk> m top 5 24h

Supports Nd (days) and Nh (hours). Uses DATE_SUB(NOW(), INTERVAL N DAY/HOUR) injected as a safe string into a concatenated query โ€” not a q{} block, so interpolation works correctly.


๐ŸŸ !slap [nick] โ€” Classic IRC Action

<teuk> m slap Boole
* mediabotv3 slaps Boole with a copy of the Camel Book

8 randomised weapons including the traditional large trout, a rubber chicken, a soggy newspaper, and a 10kg bag of CPAN modules. Delivered via CTCP ACTION.


๐Ÿ“ก Partyline .bcast <message> โ€” Broadcast to All Channels

.bcast Server restart in 5 minutes!
Broadcast sent to 3 channel(s).

Sends a [broadcast] prefixed message to every channel the bot is currently joined on. Requires Master or above. Joined channels detected via gethChannelsNicksOnChan. Available to all Partyline sessions.


๐Ÿงฎ !calclast โ€” Calc History

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

<teuk> m calclast
<mediabot> -teuk- Last calc(s):
<mediabot> -teuk-   pi * 6^2 = 113.097335529232

Stores the last 3 !calc results per nick in $self->{_calc_history}{$nick}. !calclast prints them privately. In-memory only โ€” resets on bot restart.


๐Ÿ“ !wordcount [nick] โ€” Distinct Word Count

<teuk> m wordcount Boole
<mediabot> boole: 4821 distinct word(s) on #boulets

Scans all publictext rows for the nick in CHANNEL_LOG, splits on non-word characters, and counts unique lowercased tokens. May be slow on large logs โ€” runs client-side after a full-table fetch.


๐Ÿ”— !alias <alias> <command> โ€” Command Aliases (Owner)

<teuk> m alias s seen
<mediabot> -teuk- Alias 's' => 'seen' set.

<teuk> m alias list
<mediabot> -teuk- s => seen
<mediabot> -teuk- t => top

<teuk> m alias del s
<mediabot> -teuk- Alias 's' deleted.

Stored in BOT_ALIAS table. Aliases are cached in $self->{_alias_cache}. Subcommands: alias <alias> <command>, alias del <alias>, alias list.

โš ๏ธ Requires table:

CREATE TABLE IF NOT EXISTS BOT_ALIAS (
    id_alias   INT AUTO_INCREMENT PRIMARY KEY,
    alias      VARCHAR(32) NOT NULL UNIQUE,
    command    VARCHAR(64) NOT NULL,
    created_by VARCHAR(64),
    created_at DATETIME DEFAULT NOW()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

๐Ÿ“… !streak [nick] โ€” Consecutive Days of Activity

<teuk> m streak teuk
<mediabot> teuk: 14 consecutive day(s) active on #boulets (most recent: 2026-05-12)

Fetches DISTINCT DATE(ts) from CHANNEL_LOG for the last 365 days, then walks backwards from the most recent day counting unbroken consecutive days via Time::Piece.


๐Ÿ› Bugs Fixed

Bug Fix
!remind cancel 4 โ†’ โ€œReminder set for cancel.โ€ Second dispatch table in mbCommandPublic was calling mbRemind_ctx directly, bypassing the cancel routing. Fixed both tables.
!top 5 30d โ†’ โ€œDatabase error.โ€ $period_sql inside q{} (single-quote) is never interpolated. Switched to string concatenation "..." . " WHERE c.name = ? $period_sql".
!stats total query had $period_sql in scope-less q{} Removed the spurious variable reference โ€” !stats has no period filter.
.bcast โ†’ โ€œPermission deniedโ€ for Owner Partyline level scale is inverted: Owner=0, Master=1. Check was $level >= 400 (IRC scale). Fixed to $level <= 1.
.bcast $session referenced wrong hash Was reading $self->{sessions}{$id} but auth data lives in $self->{users}{$id}. Fixed source hash.

๐Ÿ“ฆ Files Changed

File Changes
UserCommands.pm mbRemindList_ctx, mbRemindCancel_ctx, mbSlap_ctx, mbCalcLast_ctx, mbWordCount_ctx, mbAlias_ctx, mbStreak_ctx + !stats first seen + !top period filter
DBCommands.pm !calc in-memory history storage
Partyline.pm _cmd_bcast + dispatch + help + level check fix
Mediabot.pm dispatch for all new commands + remind cancel routing

You must be logged in to reply.