The bot grows wiser. This wave plugs Claude (Anthropic) directly into the
IRC command line, adds YouTube search, gives !ai a conversational memory,
wires Prometheus metrics, and ships eight new test cases to lock it all in.
βAccio Intelligence! The grimoire opens. The answers flow.β π§ β¨
!ai <prompt> β Ask Claude from IRC<teuk> m ai what is the difference between TCP and UDP?
<mediabotv3> TCP guarantees delivery and ordering via acknowledgements.
UDP is connectionless and faster but unreliable.
<teuk> m ai and which one does IRC use?
<mediabotv3> IRC uses TCP β reliable delivery is essential for chat messages.
<teuk> m ai reset
<mediabotv3> -teuk- Conversation history cleared.
!ai calls the Anthropic Messages API (api.anthropic.com/v1/messages)
using claude-haiku-4-5-20251001 by default. Fully configurable:
[anthropic]
API_KEY = sk-ant-api03-β¦
MODEL = claude-haiku-4-5-20251001
MAX_TOKENS = 400
MAX_PRIVMSG = 4
WRAP_BYTES = 400
SYSTEM_PROMPT = You are a helpful IRC assistant. Be concise.
Key differences from !tellme (OpenAI):
!ai (Claude) |
!tellme (OpenAI) |
|
|---|---|---|
| Header | x-api-key |
Authorization: Bearer |
| Version | anthropic-version: 2023-06-01 |
β |
| Response | content[0]{text} |
choices[0].message.content |
| History | β per nick+channel | β stateless |
Works in private too β /msg mediabotv3 ai what is Perl? β without any
chanset restriction. In-channel requires the Claude chanset to be enabled:
m chanset #teuk +Claude.
!ai resetEach nick+channel pair maintains a rolling conversation context of up to
3 exchanges (6 messages: 3 user + 3 assistant). Every new !ai prompt
includes the full history so Claude can answer follow-up questions naturally.
<teuk> m ai what is the Hailo module used for?
<mediabotv3> Hailo is a Markov chain chatbot engine used for natural IRC replies.
<teuk> m ai does Mediabot use it?
<mediabotv3> Yes β Mediabot integrates Hailo for autonomous responses when triggered.
!ai reset clears the history for the calling nick on the current channel.
History is in-memory β reset at bot restart.
!yt search <query> β YouTube Search from IRC<teuk> m yt search perl programming tutorial
<mediabotv3> π¬ Search: perl programming tutorial -- 3 result(s)
<mediabotv3> [1] Learning Perl in 2024 - by PerlMonks - https://youtu.be/xAbCdEfG123
<mediabotv3> [2] Perl Tutorial for Beginners - by CodeAcademy - https://youtu.be/yHiJkLmNo456
<mediabotv3> [3] Modern Perl Best Practices - by teuk.org - https://youtu.be/zPqRsTuvW789
Uses the YouTube Data API v3 search endpoint β same API key as !yt <url>.
Returns 3 results with title, channel, and direct link using the existing
_yt_* colour helpers. Requires chanset Youtube. ALL-CAPS titles are
normalised to Title Case automatically.
!yt <url> continues to work exactly as before β the routing is:
!yt search <query> β ytSearch_ctx()
!yt <url> β youtubeSearch_ctx() (existing behaviour)
.stats [#chan].stats #boulets
Stats for #boulets:
----------------------------------------
Top speakers:
1. teuk 1247 msgs
2. Poyan 844 msgs
3. Boole 312 msgs
Top karma:
teuk +14
Boole +7
Poyan +3
----------------------------------------
Top 3 speakers from CHANNEL_LOG + top 3 karma from KARMA table in a
single Partyline command. Channel defaults to the first joined channel if
not specified.
!aiTwo new counters visible in Grafana:
mediabot_claude_requests_total β incremented on every successful Claude reply
mediabot_claude_errors_total β incremented on HTTP/API errors
Same pattern as existing mediabot_commands_public_total β no new
configuration required.
displayYoutubeDetails() now caches results by video ID for 5 minutes
(YT_CACHE_TTL = 300). A second !yt <same-url> in the same window returns
instantly from cache β no API call, no quota hit.
Cache entries older than 50 minutes are evicted automatically on each write.
| # | File | What |
|---|---|---|
| 217 | 217_usercommands_karma_cap.t |
processKarma caps at 3 per message (C2) |
| 218 | 218_usercommands_poll_deadline.t |
Poll deadline + !vote expiry (B7) |
| 219 | 219_usercommands_trivia_guard.t |
checkTriviaAnswer eval guard (B3) |
| 220 | 220_external_claude_api.t |
Claude uses Anthropic headers, not OpenAI |
| 221 | 221_external_yt_cache.t |
YT_CACHE_TTL constant + cache check + store |
| 222 | 222_external_claude_chanset_gate.t |
_chanset_ok('Claude') before HTTP |
| 223 | 223_external_yt_search.t |
ytSearch_ctx endpoint, results, chanset |
| 224 | 224_external_claude_history.t |
History build, splice cap, reset command |
All follow the static-analysis pattern of the existing 216 test cases β no live server or DB required.
| File | Changes |
|---|---|
External.pm |
claudeAI, claude_ctx (S4), ytSearch_ctx (P1), yt cache (S5), conversation history (P2), chanset gate (P6), Prometheus metrics (P5) |
Partyline.pm |
_cmd_stats (S8) |
Mediabot.pm |
!ai dispatch (public + private), !yt search routing |
t/cases/217β¦224 |
8 new test cases |
You must be logged in to reply.