No flashy new commands this time β just the quiet work of making everything sharper. Ten subs gained tracing, Claude got smarter memory management, YouTube search learned to show duration and view counts, and the Partyline grew a direct line to Claude. Plus a prompt cache to save API quota.
βLumos Maxima! Every dark corner illuminated, every rough edge smoothed.β π―οΈβ¨
logBot() Added to 8 CommandsThe following commands were posting public IRC output with no trace in the bot logs β now fixed:
| Command | Sub | Action logged |
|---|---|---|
!streak |
mbStreak_ctx |
target nick |
!flip |
mbFlip_ctx |
result (Heads/Tails) |
!when |
mbWhen_ctx |
target nick |
!pollresult |
mbPollResult_ctx |
empty tag |
!triviascore |
mbTriviaScore_ctx |
empty tag |
!choose |
mbChoose_ctx |
chosen option |
!abbrev |
mbAbbrev_ctx |
resulting acronym |
!vote |
mbVote_ctx |
option voted for |
All now traceable in action logs and in the console channel notice.
$self->{_claude_history} was growing indefinitely β every nick that quit
left its conversation context in memory forever.
Two hooks added to mediabot.pl:
on_message_QUIT β deletes all history keys matching lc($sNick)\x00*
on_message_NICK β same, using $sNick_n (the local variable for the
changing nick, distinct from $sNick used in the QUIT handler)
my $prefix = lc($sNick) . "\x00";
delete $mediabot->{_claude_history}{$_}
for grep { index($_, $prefix) == 0 } keys %{ $mediabot->{_claude_history} };
!ai history<teuk> m ai history
<mediabotv3> -teuk- 4 message(s) in context:
<mediabotv3> -teuk- [user] what is TCP?
<mediabotv3> -teuk- [assistant] TCP guarantees delivery and ordering via...
<mediabotv3> -teuk- [user] and UDP?
<mediabotv3> -teuk- [assistant] UDP is connectionless and faster but unreliable.
Shows the current conversation context (up to 6 messages) for the calling
nick on the current channel. Delivered privately via botNotice.
Content truncated at 120 chars per message for readability.
.ai <prompt>.ai what version of Perl does Mediabot use?
[Claude] Mediabot uses Perl 5 β specifically Net::Async::IRC for the event loop.
Calls claudeAI() directly from the Partyline session. Uses a lightweight
local *Mediabot::Helpers::botPrivmsg override to capture bot output into
the stream instead of sending it to IRC. Falls back to (no response) if
Claude returns nothing.
No chanset gate β Partyline sessions are already authenticated.
!uptime β Claude Request Counter (F54)<teuk> m uptime
<mediabotv3> mediabotv3: up 3h 14m 7s | RAM 52.1 MB | load 0.08 0.05 0.01 | AI 23 req(s)
Reads mediabot_claude_requests_total from the Prometheus metrics registry.
Only shown if non-zero β keeps the line clean when !ai hasnβt been used yet.
!yt search β Duration & View Count (F51)<teuk> m yt search perl tutorial 2024
<mediabotv3> π¬ Search: perl tutorial 2024 -- 3 result(s)
<mediabotv3> [1] Modern Perl in 2024 - by PerlMonks [12:34] 48.2K views - https://youtu.be/β¦
<mediabotv3> [2] Learning Perl Fast - by CodeCraft [8:21] 12.7K views - https://youtu.be/β¦
<mediabotv3> [3] Perl Best Practices - by teuk.org [24:07] 3.1K views - https://youtu.be/β¦
A second API call to videos?part=contentDetails,statistics fetches duration
and view count for all result IDs in one batch request. Duration is parsed from
ISO 8601 (PT4M13S β 4:13). View counts are formatted as 1.2M / 48K.
!ai Prompt Cache (60s TTL)If the exact same prompt (case-insensitive) is asked again within 60 seconds, Claude is not called β the cached answer is returned immediately.
require Digest::MD5;
my $prompt_key = Digest::MD5::md5_hex(lc($prompt));
my $pcache = $self->{_claude_prompt_cache}{$prompt_key};
if ($pcache && (time() - $pcache->{ts}) < 60) {
# serve from cache
}
Cache entries older than 120 seconds are evicted on the next write. The cached answer is still injected into the conversation history so context remains coherent.
$sNick vs $sNick_n in on_message_NICKThe Q2 NICK purge used $sNick β which doesnβt exist in on_message_NICK
(the local variable is $sNick_n). This caused a Global symbol "$sNick" requires explicit package name compilation error at startup.
Fix: replaced $sNick with $sNick_n in the two affected lines.
| File | Changes |
|---|---|
UserCommands.pm |
Q1: logBot() in streak, flip, when, pollresult, triviascore, choose, abbrev, vote |
External.pm |
F50 !ai history, F51 yt duration+views, F53 prompt cache (60s) |
Partyline.pm |
F52 .ai <prompt> command |
Mediabot.pm |
F54 !uptime + Claude counter |
mediabot.pl |
Q2 QUIT/NICK history purge + bugfix $sNick_n |
You must be logged in to reply.