Skip to content

IRCv3 batch support - #1938

Open
vanosg wants to merge 16 commits into
developfrom
feature/batch
Open

vanosg wants to merge 16 commits into
developfrom
feature/batch

Conversation

@vanosg

@vanosg vanosg commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Patch by: Geo

One-line summary:
Add IRCv3 batch capability support, and use netsplit batches for netsplit detection

Additional description (if needed):

  • Adds support for the 'batch' IRCv3 command (enables tracking of start and finish, stale batches)
  • Adds a Tcl bind for batch, with the ability to track batch start, batch complete or batch discard (stale) events:
  bind batch <flags> <type> <proc>
  proc mybatch {reftag type event parent args tags}
  • Adds support for the netsplit, netjoin, and labeled-response types of batch command
  • Updates existing SPLT/REJN binds to trigger on netsplit/netjoin types
  • Adds batch and labeled-response config vars

Test cases demonstrating functionality (if applicable):

.tcl proc bt {r t p e pa} {putlog "BATCH $e: $r type=$t parent=$pa params=$p"} ; bind batch - * bt
.tcl proc sp {n uh hand chan} {putlog "Net SPLIT detected: $n ($uh) split from $chan"} ; bind splt - * sp
.tcl proc rj {n uh hand chan} {putlog "Net REJOIN detected: $n ($uh) rejoined $chan"} ; bind rejn - * rj



[00:33:59] BATCH start: L1 type=example.com/foo parent= params=
[00:33:59] BATCH start: L2 type=example.com/foo parent=L1 params=
[00:33:59] BATCH start: L3 type=example.com/foo parent=L2 params=
[00:33:59] BATCH end: L3 type=example.com/foo parent=L2 params=
[00:33:59] BATCH end: L2 type=example.com/foo parent=L1 params=
[00:33:59] BATCH end: L1 type=example.com/foo parent= params=

[00:39:02] BATCH start: s1 type=netsplit parent= params=irc.hub other.host
[00:39:02] Net SPLIT detected: alice (~alice@node1.example.net) split from #eggtest
[00:39:02] Net SPLIT detected: bob (~bob@node2.example.net) split from #eggtest
[00:39:02] BATCH end: s1 type=netsplit parent= params=irc.hub other.host
[00:39:13] BATCH start: j1 type=netjoin parent= params=irc.hub other.host
[00:39:13] Net REJOIN detected: alice (~alice@node1.example.net) rejoined #eggtest
[00:39:13] Net REJOIN detected: bob (~bob@node2.example.net) rejoined #eggtest
[00:39:13] BATCH end: j1 type=netjoin parent= params=irc.hub other.host


[00:39:23] Net SPLIT detected: carol (~carol@node3.example.net) split from #eggtest
.channel
 NICKNAME  HANDLE    ACCOUNT    JOIN   IDLE         USER@HOST
@BeerBot   *                   00:38                <- it's me!
 alice     *                    ---                 ~alice@node1.example.net
 bob       *                    ---                 ~bob@node2.example.net
 carol     *                    ---                 <- netsplit, 3s



.tcl proc ba {r t e p a tg} {putlog "-=BATCH reftag=$r type=$t event=$e parent=$p args=$a tags=$tg"} ; bind batch - * ba
.tcl proc lb {f c x tg} {if {[dict exists $tg label] && ![dict exists $tg batch]} {putlog "-= LABEL [dict get $tg label]: $c $x"} ; return 0} ; bind rawt - * lb

[16:18:04] -=BATCH reftag=lblparent type=example.com/foo event=start parent= args= tags=
[16:18:04] -=BATCH reftag=lostref type=labeled-response event=start parent=lblparent args= tags=label lbl-lost batch lblparent
[16:18:04] -=BATCH reftag=lblparent type=example.com/foo event=end parent= args= tags=
[16:18:04] -=BATCH reftag=lostref type=labeled-response event=discard parent=lblparent args= tags=label lbl-lost batch lblparent
[16:18:05] *** LABEL lbl-multi: BATCH +multiref labeled-response
[16:18:05] -=BATCH reftag=multiref type=labeled-response event=start parent= args= tags=label lbl-multi time 2026-09-13T22:00:00.000Z
[16:18:06] -=BATCH reftag=multiref type=labeled-response event=end parent= args= tags=label lbl-multi time 2026-09-13T22:00:00.000Z

@vanosg vanosg added this to the 1.10.3 milestone Sep 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c834bafb3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mod/server.mod/servmsg.c Outdated
@vanosg

vanosg commented Sep 20, 2026 •

Copy link
Copy Markdown
Member Author

Incorporated @thommey's feedback on providing the option to avoid triggering previous binds in commands like chathistory by adding a 'suppress' member to the batch struct and checking it on batch sessions. If suppress is set to 1, check_tcl_raw is not called, which is where the other binds are called from (pub, msg, join, etc).

In short similar to rawt- if check_tcl_batch returns 1, set suppressed to 1. Every subsequent line is run checks message tags for a batch reference and pulls the record from the batch table. If suppress is set to 1, don't trigger check_tcl_raw.

Does this inject processing issues I'm not considering? Is it ok to check this every line like this? It feels heavy

putlog(LOG_DEBUG, "*", "BATCH: opened %s (type %s)%s%s", b->reftag,
b->type, b->parent ? ", nested in " : "",
b->parent ? b->parent->reftag : "");
/* Suppress session if parent session is suppressed */

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Come back and check this

@vanosg

vanosg commented Sep 22, 2026

Copy link
Copy Markdown
Member Author
.tcl bind rawt - * gb
.tcl proc gb {f c x tg} {if {[dict exists $tg batch]} {putlog "GETBATCH: [getbatch [dict get $tg batch]]"} ; return 0} 
[22:33:27] #-HQ# dump @label=1234 CHATHISTORY LATEST #eggtest * 10
[22:33:27] [!s] @label=1234 CHATHISTORY LATEST #eggtest * 10
[22:33:28] [s->] @label=1234 CHATHISTORY LATEST #eggtest * 10
[22:33:28] [@] @label=1234 :testnet.ergo.chat BATCH +4 chathistory #eggtest
[22:33:28] [@] @msgid=_g8vyu9hbxvnkgi4gsvvr47xmhw;batch=4 :HistServ!HistServ@localhost PRIVMSG #eggtest :BeerBot quit (Quit: )
**[22:33:28] GETBATCH: reftag 4 type chathistory args #eggtest tags {label 1234} parent {} suppress 0 started 1790116408 seq 3**
[22:33:28] [@] @msgid=_2a8mdpcueednkkx35a3vra2236;batch=4 :HistServ!HistServ@localhost PRIVMSG #eggtest :BeerBot joined the channel
**[22:33:28] GETBATCH: reftag 4 type chathistory args #eggtest tags {label 1234} parent {} suppress 0 started 1790116408 seq 3**
[22:33:28] [@] @msgid=3mcybpipczcg633bseacgmpgnn;batch=4 :Geo!~u@k7k72hw4xk28y.irc PRIVMSG #eggtest :!test
**[22:33:28] GETBATCH: reftag 4 type chathistory args #eggtest tags {label 1234} parent {} suppress 0 started 1790116408 seq 3**
<...>
[22:33:28] [@] :testnet.ergo.chat BATCH -4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant