Forum teuk.org

🧙 Mediabot v3: Hardening the DCC Partyline Like a Real IRC Bot

in Mediabot · started by TeuK · 1w ago

TeuK · 1w ago

🧙 Mediabot v3: Hardening the DCC Partyline Like a Real IRC Bot

Another important milestone has been reached for Mediabot v3.

This update focuses on the Partyline and DCC/CTCP handling, with one goal: make the bot more solid, more maintainable, and closer to the spirit of classic Eggdrop-style administration, while keeping Mediabot’s own architecture.

This is not just a cosmetic cleanup. The DCC Partyline path is now cleaner, better tested, easier to debug, and more useful for real administration.


What changed

The main improvements are:

centralized DCC / CTCP parsing
cleaner Partyline DCC handling
optional low-level DCC debug
reverse DNS display for Partyline users
safer and clearer tests

The result is a Partyline that behaves more like a serious IRC administration tool.


DCC / CTCP parsing is now centralized

A dedicated module now handles DCC and CTCP parsing:

Mediabot/DCC.pm

It provides helpers such as:

parse_ctcp_payload()
parse_dcc_payload()
parse_dcc_chat_payload()
is_ctcp_chat()
is_dcc_chat()
is_dcc_active()
is_dcc_passive()
ip_int_to_ipv4()

This means the fragile parsing logic no longer lives directly inside mediabot.pl.

Before, several DCC and CTCP formats were handled inline with regexes in different places.

Now, Mediabot has one central parser for payloads such as:

\x01CHAT\x01
\x01DCC CHAT chat <ip_int> <port>\x01
\x01DCC CHAT chat 0 0 <token>\x01
CHAT chat <ip_int> <port>
DCC CHAT chat <ip_int> <port>

This reduces duplication and makes the behavior easier to test.


Runtime now uses the shared parser

mediabot.pl now routes DCC and CTCP payloads through Mediabot::DCC.

This protects the old fragile case where /dcc chat <botnick> could be interpreted as a private command named:

dcc

and end up with:

Private command 'dcc' not found

That regression is now covered by tests.


Direct CTCP DCC handler improved

The direct CTCP DCC handler now also uses the shared DCC parser.

Instead of manually stripping CTCP delimiters and parsing DCC CHAT with inline regexes, it now relies on:

parse_dcc_payload()
is_dcc_chat()

This makes the handler more consistent with the rest of the runtime.


Optional DCC debug hints

Low-level DCC diagnostics are now controlled by a configuration option:

DCC_DEBUG_HINTS=0

When disabled, Mediabot avoids dumping noisy CTCP hint/debug information.

When enabled, it can still log useful low-level payload information for troubleshooting DCC client behavior.

This keeps normal logs clean while preserving the ability to debug difficult IRC client cases.


Partyline reverse DNS display

The Partyline now performs reverse DNS lookups for connected users, with a short timeout.

Instead of only showing raw IP addresses, .whom can now display:

teuk@localhost/127.0.0.1
teuk@teuk.org/46.105.124.96
teuk@xxxx.abo.wanadoo.fr/XXX.XXX.XXX.XXX

The important rule is:

the IP address is never truncated
only the reverse DNS part may be shortened if needed

For administration, the IP is the reliable information. The reverse DNS name is useful context.


Cleaner Partyline user display

The Partyline user list now uses the common display helper instead of reconstructing nick/host strings manually.

This means both telnet and DCC Partyline sessions can be displayed consistently.

The output is now much more useful for live administration.


Tests improved

The DCC parser and runtime paths are now covered by dedicated tests:

t/cases/10_dcc_ctcp_regression.t
t/cases/11_dcc_parser.t

The tests validate:

raw CTCP CHAT
raw CTCP DCC CHAT
stripped DCC CHAT
passive DCC CHAT tokens
invalid DCC payloads
parser predicate helpers
runtime wiring through Mediabot::DCC
Partyline behavior

The full test suite was run successfully after the changes.


Real-world validation

The following access paths were tested successfully:

/dcc chat mediabotv3
/ctcp mediabotv3 CHAT
telnet localhost 23456
.whom

The Partyline login flow still works, passwords are not echoed, DCC sessions still authenticate correctly, and .whom now shows useful reverse DNS / IP information.


Files involved

Main files touched by this milestone:

Mediabot/DCC.pm
Mediabot/Partyline.pm
mediabot.pl
mediabot.sample.conf
t/cases/10_dcc_ctcp_regression.t
t/cases/11_dcc_parser.t

Suggested commit

🧙 Portus Parserum: centralize and harden DCC Partyline parsing

This is a strong internal cleanup.

It does not just add a feature. It makes the DCC Partyline path more reliable, more testable, and more pleasant to operate.

Mediabot v3 is moving one step closer to the feel of a real Eggdrop-style IRC bot, while keeping its own Perl architecture and modern testing workflow.

You must be logged in to reply.