mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
capability: Add extended-join and userhost-in-names
This commit is contained in:
parent
ef592d160c
commit
e33a810522
@ -20,7 +20,9 @@ Initial release of Oragono!
|
||||
* We now advertise the [`RPL_ISUPPORT`](http://modern.ircdocs.horse/#rplisupport-005) numeric.
|
||||
* Parse new mode change syntax commonly used these days (i.e. `+h-ov dan dan dan`).
|
||||
* User mode for clients connected via TLS (`+Z`).
|
||||
* Support for [`extended-join`](http://ircv3.net/specs/extensions/extended-join-3.1.html).
|
||||
* Support for [`server-time`](http://ircv3.net/specs/extensions/server-time-3.2.html).
|
||||
* Support for [`userhost-in-names`](http://ircv3.net/specs/extensions/userhost-in-names-3.2.html).
|
||||
|
||||
### Changed
|
||||
* Added channel Founder/Admin/Halfops (`qah`) privileges, and removed channel creator (`O`) privilege (from RFC2812, not used in the real world).
|
||||
|
@ -14,15 +14,19 @@ import (
|
||||
type Capability string
|
||||
|
||||
const (
|
||||
MultiPrefix Capability = "multi-prefix"
|
||||
SASL Capability = "sasl"
|
||||
ServerTime Capability = "server-time"
|
||||
ExtendedJoin Capability = "extended-join"
|
||||
MultiPrefix Capability = "multi-prefix"
|
||||
SASL Capability = "sasl"
|
||||
ServerTime Capability = "server-time"
|
||||
UserhostInNames Capability = "userhost-in-names"
|
||||
)
|
||||
|
||||
var (
|
||||
SupportedCapabilities = CapabilitySet{
|
||||
MultiPrefix: true,
|
||||
ServerTime: true,
|
||||
ExtendedJoin: true,
|
||||
MultiPrefix: true,
|
||||
ServerTime: true,
|
||||
UserhostInNames: true,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -109,11 +109,16 @@ func (modes ChannelModeSet) Prefixes(isMultiPrefix bool) string {
|
||||
|
||||
func (channel *Channel) Nicks(target *Client) []string {
|
||||
isMultiPrefix := (target != nil) && target.capabilities[MultiPrefix]
|
||||
isUserhostInNames := (target != nil) && target.capabilities[UserhostInNames]
|
||||
nicks := make([]string, len(channel.members))
|
||||
i := 0
|
||||
for client, modes := range channel.members {
|
||||
nicks[i] += modes.Prefixes(isMultiPrefix)
|
||||
nicks[i] += client.Nick().String()
|
||||
if isUserhostInNames {
|
||||
nicks[i] += client.nickMaskString
|
||||
} else {
|
||||
nicks[i] += client.nickString
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
return nicks
|
||||
@ -203,7 +208,11 @@ func (channel *Channel) Join(client *Client, key string) {
|
||||
}
|
||||
|
||||
for member := range channel.members {
|
||||
member.Send(nil, client.nickMaskString, "JOIN", channel.nameString)
|
||||
if member.capabilities[ExtendedJoin] {
|
||||
member.Send(nil, client.nickMaskString, "JOIN", channel.nameString, client.accountName, client.realname)
|
||||
} else {
|
||||
member.Send(nil, client.nickMaskString, "JOIN", channel.nameString)
|
||||
}
|
||||
}
|
||||
|
||||
client.channels.Add(channel)
|
||||
@ -214,7 +223,11 @@ func (channel *Channel) Join(client *Client, key string) {
|
||||
channel.members[client][ChannelOperator] = true
|
||||
}
|
||||
|
||||
client.Send(nil, client.nickMaskString, "JOIN", channel.nameString)
|
||||
if client.capabilities[ExtendedJoin] {
|
||||
client.Send(nil, client.nickMaskString, "JOIN", channel.nameString, client.accountName, client.realname)
|
||||
} else {
|
||||
client.Send(nil, client.nickMaskString, "JOIN", channel.nameString)
|
||||
}
|
||||
channel.GetTopic(client)
|
||||
channel.Names(client)
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ type Client struct {
|
||||
nickMaskString string // cache for nickmask string since it's used with lots of replies
|
||||
quitTimer *time.Timer
|
||||
realname string
|
||||
accountName string
|
||||
registered bool
|
||||
server *Server
|
||||
socket *Socket
|
||||
@ -65,6 +66,7 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
|
||||
flags: make(map[UserMode]bool),
|
||||
server: server,
|
||||
socket: &socket,
|
||||
accountName: "*", // * is used until actual account name is set
|
||||
nickString: "*", // * is used until actual nick is given
|
||||
}
|
||||
if isTLS {
|
||||
|
@ -423,7 +423,7 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
||||
client.username = Name("~" + msg.Params[0])
|
||||
client.updateNickMask()
|
||||
}
|
||||
if client.realname != "" {
|
||||
if client.realname == "" {
|
||||
client.realname = msg.Params[3]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user