fix: use client nick for synthetic JOINs and own-nick rewriting
irssi (and other IRC clients) only open a channel window when they see a JOIN from their own nick. The synthetic JOINs were using the network nick (e.g. pagumowa) but the client registered as tester -- mismatch. Three changes: - Synthetic JOIN prefix is now client_nick!user@bouncer - 001 welcome uses the client's registered nick - encode_nick/encode_message accept client_nick param to rewrite own nicks from any network to the client's nick, so irssi recognizes all self-actions consistently Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,12 @@ class TestEncodeNick:
|
||||
# Own nick on another network still shown bare
|
||||
assert encode_nick("mybot2", "libera", OWN) == "mybot2"
|
||||
|
||||
def test_own_nick_rewritten_to_client_nick(self):
|
||||
assert encode_nick("mybot", "libera", OWN, client_nick="tester") == "tester"
|
||||
|
||||
def test_foreign_nick_unaffected_by_client_nick(self):
|
||||
assert encode_nick("user123", "libera", OWN, client_nick="tester") == "user123/libera"
|
||||
|
||||
|
||||
class TestEncodePrefix:
|
||||
def test_full_prefix(self):
|
||||
@@ -141,3 +147,22 @@ class TestEncodeMessage:
|
||||
)
|
||||
out = encode_message(msg, "libera", OWN)
|
||||
assert out.raw is None # raw must not carry over
|
||||
|
||||
def test_own_prefix_rewritten_to_client_nick(self):
|
||||
msg = IRCMessage(
|
||||
command="PRIVMSG",
|
||||
params=["#test", "hello"],
|
||||
prefix="mybot!ident@host",
|
||||
)
|
||||
out = encode_message(msg, "libera", OWN, client_nick="tester")
|
||||
assert out.prefix == "tester!ident@host"
|
||||
|
||||
def test_namreply_own_nick_rewritten(self):
|
||||
msg = IRCMessage(
|
||||
command="353",
|
||||
params=["mybot", "=", "#test", "@op mybot"],
|
||||
)
|
||||
out = encode_message(msg, "libera", OWN, client_nick="tester")
|
||||
names = out.params[3].split()
|
||||
assert names[0] == "@op/libera"
|
||||
assert names[1] == "tester"
|
||||
|
||||
Reference in New Issue
Block a user