Make "@" and "/" indicate client name and network, respectively

This allows both kinds "<username>@<client>/<network>" and
"<username>/<network>@<client>".
This commit is contained in:
Simon Ser 2020-03-31 19:02:02 +02:00
parent 8e6eb18d09
commit 73ee7d237f
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 13 additions and 2 deletions

View File

@ -37,6 +37,9 @@ soju supports two connection modes:
a channel, you need to use the suffix too: _/join #channel/network_. Same a channel, you need to use the suffix too: _/join #channel/network_. Same
applies to messages sent to users. 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 "@<client>" suffix to the username.
# OPTIONS # OPTIONS
*-h, -help* *-h, -help*

View File

@ -540,10 +540,18 @@ func unmarshalUsername(rawUsername string) (username, client, network string) {
username = rawUsername[:i] username = rawUsername[:i]
} }
if j >= 0 { 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 { 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 return username, client, network