Forum teuk.org

πŸͺ„ Nox et Lumos! β€” Floodguards Forged, Intelligence Sharpened (May 2026)

in Mediabot Β· started by TeuK Β· 1mo ago

TeuK Β· 1mo ago

Overview

Two spells in one breath. Nox silences the floods β€” four new antiflood guards protect every channel, especially #quebec. Lumos brings clarity β€” seven intelligence features sharpen commands, responses, and operator tools. Plus the usual audit, bug-hunting, and 15 new test cases.

β€œNox! The floods are silenced. Lumos! The bot shines brighter than ever.” 🏰⚑🌟


πŸ›‘οΈ AF1 β€” checkAntiFlood β€” Zero DB per Outgoing Message

The old checkAntiFlood fired 6 SQL queries per outgoing message on a +AntiFlood channel. The new version caches parameters in memory (_af_params, TTL 60s) and tracks flood state in _af:

Before: SELECT β†’ UPDATE β†’ SELECT β†’ UPDATE β†’ ... (6 round-trips/msg)
After:  one SELECT per channel every 60s β€” zero DB during floods

Silence state is stored as silenced_until β€” checked in < 1Β΅s.


πŸ”” AF2 β€” checkNickFlood β€” User Notification

Previously silent: a flooding nick was dropped without explanation. Now the nick receives a NOTICE at most once every 30 seconds:

-mediabotv3- You are sending commands too fast. Please wait 3s.

πŸ” AF3 β€” checkNickFlood β€” Sliding Window

The old fixed window allowed bursting: 4 cmds at t=4.9s + 4 at t=5.1s = 8 cmds undetected. The new implementation keeps a ring buffer of timestamps and prunes entries older than the window on every call β€” the burst is caught regardless of timing.


🌊 AF4 β€” checkChanFlood β€” Global Per-Channel Input Guard

Brand new sub. Counts all incoming commands on a channel, all nicks combined. If >8 commands in 10s β†’ channel silenced for 30s.

Five nicks spam #quebec simultaneously
  ↓ checkChanFlood(#quebec) β†’ 9 cmds/10s β†’ SILENCED 30s
  ↓ checkNickFlood(nick, #quebec) β†’ sliding window β†’ NOTICE
  ↓ command processed

Configurable per channel from the Partyline:

.floodset #quebec 10 4 60     ← window=10s, max=4, silence=60s
.cmdcooldown #quebec ai 20    ← !ai cooldown 20s on #quebec

πŸ’€ CC3 / AF7 β€” Three-Strike Auto-Mute

After triggering checkNickFlood three times in a row, the nick is added to _nick_mute for 5 minutes β€” silently dropped with zero DB interaction. Operators can lift it instantly:

.unmute spammer
AF7 mute lifted for spammer.

.floodstatus now shows all three layers at once:

--- Channel antiflood (AF1 β€” output guard) ---
  #boulets     3 msgs in window
  #quebec      SILENCED (18s remaining)
--- Channel flood (AF4 β€” input guard) ---
  #quebec      SILENCED (18s remaining)
--- Temp mutes (CC3/AF7) ---
  spammer      muted (247s remaining)
--- Per-nick flood (AF3) ---
  spammer      6 cmds in window

⏱️ CC1 β€” Per-Command Cooldown

!ai and !trivia now have a default per-channel cooldown (10s and 5s respectively). Configurable with .cmdcooldown:

<teuk> m ai explain IPv6
<mediabotv3> -teuk- !ai is cooling down on #boulets β€” wait 8s.

🏷️ CC4 β€” !trivia Named Categories

20 named categories map to Open Trivia DB IDs:

<teuk> m trivia history
<mediabotv3> Trivia (History): Who was the first President of the United States?

<teuk> m trivia categories
<mediabotv3> Trivia categories: animals, anime, art, books, cartoons, celebrities, computers...

Full list: general science computers maths sports geography history politics art celebrities animals vehicles comics gadgets anime tv music film books mythology.


πŸ“Š CC6 β€” .top all [n] β€” All-Channel Leaderboard

.top all 5
Top 5 speakers (all channels):
   1. teuk              18,432 msgs
   2. Boole             12,847 msgs
   3. Poyan              9,201 msgs

The existing .top #chan [n] is unchanged. all is a new keyword.


πŸ“‹ CC7 β€” !remindlist Enriched

<teuk> m remindlist
<mediabotv3> 2 pending reminder(s) you have set:
<mediabotv3>   #3 -> boole [in 2h 30m]: apporte les logs [URGENT]
<mediabotv3>   #7 -> poyan [overdue 15m ago]: rΓ©union

Remaining time is shown in human-readable form (_seconds_to_human). [URGENT] appears for reminders set with !remind ! nick msg. Overdue reminders show how long ago they passed.


πŸ€– DD1 β€” !ai Response Cache (60s)

Identical prompts on the same channel return the cached answer instantly (no API call) for 60 seconds. Uses the existing _claude_prompt_cache hash (F53), extended to check before firing the API:

<teuk> m ai quel est le 6Γ¨me gaz noble ?
<mediabotv3> Le radon (Rn, numΓ©ro 86)...
<boole> m ai quel est le 6Γ¨me gaz noble ?  ← 30s later
<mediabotv3> [cache] Le radon (Rn, numΓ©ro 86)...  ← instant, no API call

🧠 DD5 β€” !ai Persona Auto-Reset After 1h Inactivity

If no !ai command has been issued on a channel for more than 1 hour, the persona is automatically cleared. Prevents stale personas from bleeding into new conversations long after the original user is gone.


🎯 DD2 β€” Per-Command Invocation Metrics

Every dispatched IRC command increments mediabot_command_total{cmd} via inc_label. Grafana can now show which commands are most used, per time window.


⏳ DD6 β€” Trivia Timeout Shows Category

Before: Time's up! The answer was: serendipity
After:  Time's up! The answer was: serendipity (General Knowledge)

The category is stored in _trivia{$channel}{category} at question start and appended to the timeout message.


πŸ”€ DD8 β€” !choose Deduplicates Options

<teuk> m choose pizza | pizza | sushi
<mediabotv3> -teuk- Note: 1 duplicate option(s) removed.
<mediabotv3> teuk: I choose... sushi!

Deduplication is case-insensitive and preserves the first occurrence.


πŸ›‘ DD9 β€” Karma Anti-Brigade

If more than 5 different votes target the same nick within 30 seconds, further votes are blocked and the channel is notified:

<mediabotv3> Karma brigade detected for teuk β€” votes temporarily blocked.

The ring buffer self-cleans when the 30s window expires.


🧹 DD10 β€” Memory Cleanup Scheduler (every 5 min)

A new memory_cleanup task runs every 300 seconds and evicts:

  • Expired _nick_mute entries (CC3/AF7)
  • Stale _cmd_cooldown entries older than 1h (CC1)
  • Inactive _chan_flood entries (AF4)
  • Expired _claude_prompt_cache entries > 120s (DD1/F53)
  • Empty _karma_brigade ring buffers (DD9)

πŸ› Bug Fix β€” External.pm compilation

DD1 and DD5 blocks referenced @args_remaining (undeclared) and $hist_key (declared further down in the same sub). Fixed:

Was Is
@args_remaining @args
$hist_key $persona_key (already declared at insertion point)

πŸ“¦ Files Changed

File Changes
Helpers.pm AF1 (checkAntiFlood rewrite), AF2+AF3 (checkNickFlood), AF4 (checkChanFlood new), CC1 (checkCmdCooldown new), CC2 overrides, CC3 strikes+mute
Mediabot.pm AF4+CC1 call sites, DD2 metrics
Partyline.pm CC2 (.floodset, .cmdcooldown), CC3 (.unmute), CC6 (.top all), .floodstatus enriched
UserCommands.pm CC4 trivia categories, CC7 remindlist, DD6 timeout category, DD8 choose dedup, DD9 karma brigade
External.pm DD1 cache check, DD5 persona reset, fix @args/@persona_key
Metrics.pm 5 new counters (nickflood_mutes, cmdcooldown_blocks, karma_brigade_blocks, antiflood_blocks, chanflood_blocks)
mediabot.pl DD10 memory_cleanup scheduler

You must be logged in to reply.