Forum teuk.org

๐Ÿช„ Alohomora! โ€” Mediabot v3 Feature Wave III (May 2026)

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

TeuK ยท 3d ago

Overview

Nine more doors unlocked. Wave III brings community tools, analytics depth, and Partyline power โ€” karma, polls, last-message lookup, personal notes, enriched uptime, and three new Partyline commands. Every spell tested in production, every bug caught before it could curse anyone.

โ€œAlohomora! The locks yield. The features flow.โ€ ๐Ÿ”“โœจ


โšก nick++ / nick-- โ€” Karma System

<Boole> teuk++
<mediabotv3> teuk's karma: +1

<teuk> m karma Boole
<mediabotv3> Boole: karma +7

<Te[u]K> Te[u]K++
<mediabotv3> Te[u]K: you can't change your own karma.

Karma increments are detected automatically on every public message via a hook in on_message_PRIVMSG. The pattern [^\s+\-]{2,32}(\+\+|--) avoids the greedy \S+ trap that would consume the ++ before the operator group could catch it. Self-karma is blocked silently โ€” now with a public notice so the user knows why nothing happened.

!karma [nick] shows the current score. Stored in the KARMA table with ON DUPLICATE KEY UPDATE score = score + ?.

โš ๏ธ Requires table:

CREATE TABLE IF NOT EXISTS KARMA (
    id_karma   INT AUTO_INCREMENT PRIMARY KEY,
    id_channel INT NOT NULL,
    nick       VARCHAR(64) NOT NULL,
    score      INT DEFAULT 0,
    UNIQUE KEY uniq_chan_nick (id_channel, nick)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

๐Ÿ’ฌ !last <nick> โ€” Last Message

<teuk> m last Boole
<mediabotv3> Boole last said (42m ago on #boulets): "bon alors ce kafka c'est chaud hein"

Fetches the most recent publictext from CHANNEL_LOG for the nick on the current channel. Formats elapsed time as Xm ago, Xh Xm ago, or Xd Xh ago using TIMESTAMPDIFF(MINUTE, ts, NOW()).


๐Ÿ“Š !poll / !vote / !pollresult / !pollstop โ€” Channel Polls

<teuk> m poll Best language? | Perl | Python | Go
<mediabotv3> Poll: "Best language?"  [1] Perl  [2] Python  [3] Go  -- vote with !vote <n>

<Boole> m vote 1
<mediabotv3> Boole voted for "Perl" (3 vote(s) cast)

<teuk> m pollresult
<mediabotv3> Active poll: "Best language?" (3 vote(s))
<mediabotv3>   [1] Perl                 2 vote(s) (67%)
<mediabotv3>   [2] Python               1 vote(s) (33%)
<mediabotv3>   [3] Go                   0 vote(s) (0%)

In-memory polls, one active per channel. !poll and !pollstop require Master+. Options separated by |. Votes stored as nick => index โ€” one vote per nick, last vote wins.


โฑ๏ธ !uptime โ€” Enriched with RAM & Load

<teuk> m uptime
<mediabotv3> mediabotv3: up 2h 14m 7s | RAM 48.3 MB | load 0.12 0.08 0.05

Reads VmRSS from /proc/self/status for resident RAM and the three load averages from /proc/loadavg. Gracefully falls back to ? if unavailable (non-Linux systems).


๐Ÿ“ !note <message> / !notes [del <n>] โ€” Personal Notes

<teuk> m note check the cron purge tomorrow
<mediabotv3> -teuk- Note saved (#1 total). Use !notes to list.

<teuk> m notes
<mediabotv3> -teuk- 1 note(s):
<mediabotv3> -teuk-   [1] check the cron purge tomorrow

<teuk> m notes del 1
<mediabotv3> -teuk- Note deleted.

In-memory only (resets on bot restart). Max 10 notes per nick. Delivered privately via botNotice.


๐Ÿ”ฎ Partyline .who <nick> โ€” Find Nick Across Channels

.who Boole
Boole is on: #boulets, #teuk

Scans all joined channels using gethChannelsNicksOnChan and reports which ones the target nick is currently present on.

Note: renamed internally to _cmd_whochan to avoid conflict with the existing _cmd_who (which lists nicks in a channel by name).


๐Ÿ“ˆ Partyline .top [#chan] [n] โ€” Top Nicks from Partyline

.top #boulets 5
Top 5 on #boulets:
   1. teuk                 1247 msgs
   2. Poyan                 844 msgs
   3. Boole                 312 msgs

Same SQL as !top but accessible from the Partyline without needing IRC.


๐Ÿ“ฌ Partyline .remind <nick> <message> โ€” Set IRC Reminder

.remind Poyan server restart at 23:00
Reminder set for Poyan on #boulets.

Inserts into REMINDERS table. Uses the first joined channel as the delivery channel. Delivered to Poyan the next time they speak on IRC.


๐Ÿ› Bugs Fixed

Bug Fix
nick++ karma never triggered โ€” \S+ consumed ++ Replaced with [^\s+\-]{2,32} which explicitly excludes + and -
Self-karma silently ignored โ€” user saw nothing Added "you can't change your own karma." public notice
Te[u]K++ still blocked even with regex fix Self-karma check extended to strip IRC bracket notation ([u]) before comparing
$target's karma โ†’ Old package separator warning Escaped apostrophe to $target\'s karma
%counts undeclared in !pollresult Changed my @counts = (0) x N (array) to my %counts (hash), fixed $counts[$i] โ†’ $counts{$i} // 0
Partyline _cmd_who redefined Our multi-channel version renamed _cmd_whochan to avoid conflict with existing _cmd_who

๐Ÿ“ฆ Files Changed

File Changes
UserCommands.pm mbKarma_ctx, processKarma, mbLast_ctx, mbPoll_ctx, mbVote_ctx, mbPollResult_ctx, mbPollStop_ctx, mbNote_ctx, mbNotes_ctx + karma regex fix + self-karma notice
Mediabot.pm !uptime enriched with RAM + load; dispatch for all new commands
Partyline.pm _cmd_whochan, _cmd_top, _cmd_remind + dispatch + help
mediabot.pl processKarma hook in on_message_PRIVMSG

You must be logged in to reply.