From 73ee7d237f8f48b56be6052e611a3a73468713e1 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 31 Mar 2020 19:02:02 +0200 Subject: [PATCH] Make "@" and "/" indicate client name and network, respectively This allows both kinds "@/" and "/@". --- doc/soju.1.scd | 3 +++ downstream.go | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/soju.1.scd b/doc/soju.1.scd index 6286c5c..54804d2 100644 --- a/doc/soju.1.scd +++ b/doc/soju.1.scd @@ -37,6 +37,9 @@ soju supports two connection modes: a channel, you need to use the suffix too: _/join #channel/network_. Same applies to messages sent to users. +For per-client history to work, clients need to indicate their name. This can +be done by adding a "@" suffix to the username. + # OPTIONS *-h, -help* diff --git a/downstream.go b/downstream.go index 4f898cc..cf6f55b 100644 --- a/downstream.go +++ b/downstream.go @@ -540,10 +540,18 @@ func unmarshalUsername(rawUsername string) (username, client, network string) { username = rawUsername[:i] } if j >= 0 { - network = rawUsername[j+1:] + if rawUsername[j] == '@' { + client = rawUsername[j+1:] + } else { + network = rawUsername[j+1:] + } } if i >= 0 && j >= 0 && i < j { - client = rawUsername[i+1 : j] + if rawUsername[i] == '@' { + client = rawUsername[i+1 : j] + } else { + network = rawUsername[i+1 : j] + } } return username, client, network