3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

capability: Add extended-join and userhost-in-names

This commit is contained in:
Daniel Oaks 2016-08-14 11:59:33 +10:00
parent ef592d160c
commit e33a810522
5 changed files with 30 additions and 9 deletions

View File

@ -20,7 +20,9 @@ Initial release of Oragono!
* We now advertise the [`RPL_ISUPPORT`](http://modern.ircdocs.horse/#rplisupport-005) numeric. * 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`). * Parse new mode change syntax commonly used these days (i.e. `+h-ov dan dan dan`).
* User mode for clients connected via TLS (`+Z`). * 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 [`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 ### Changed
* Added channel Founder/Admin/Halfops (`qah`) privileges, and removed channel creator (`O`) privilege (from RFC2812, not used in the real world). * Added channel Founder/Admin/Halfops (`qah`) privileges, and removed channel creator (`O`) privilege (from RFC2812, not used in the real world).

View File

@ -14,15 +14,19 @@ import (
type Capability string type Capability string
const ( const (
MultiPrefix Capability = "multi-prefix" ExtendedJoin Capability = "extended-join"
SASL Capability = "sasl" MultiPrefix Capability = "multi-prefix"
ServerTime Capability = "server-time" SASL Capability = "sasl"
ServerTime Capability = "server-time"
UserhostInNames Capability = "userhost-in-names"
) )
var ( var (
SupportedCapabilities = CapabilitySet{ SupportedCapabilities = CapabilitySet{
MultiPrefix: true, ExtendedJoin: true,
ServerTime: true, MultiPrefix: true,
ServerTime: true,
UserhostInNames: true,
} }
) )

View File

@ -109,11 +109,16 @@ func (modes ChannelModeSet) Prefixes(isMultiPrefix bool) string {
func (channel *Channel) Nicks(target *Client) []string { func (channel *Channel) Nicks(target *Client) []string {
isMultiPrefix := (target != nil) && target.capabilities[MultiPrefix] isMultiPrefix := (target != nil) && target.capabilities[MultiPrefix]
isUserhostInNames := (target != nil) && target.capabilities[UserhostInNames]
nicks := make([]string, len(channel.members)) nicks := make([]string, len(channel.members))
i := 0 i := 0
for client, modes := range channel.members { for client, modes := range channel.members {
nicks[i] += modes.Prefixes(isMultiPrefix) nicks[i] += modes.Prefixes(isMultiPrefix)
nicks[i] += client.Nick().String() if isUserhostInNames {
nicks[i] += client.nickMaskString
} else {
nicks[i] += client.nickString
}
i += 1 i += 1
} }
return nicks return nicks
@ -203,7 +208,11 @@ func (channel *Channel) Join(client *Client, key string) {
} }
for member := range channel.members { 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) client.channels.Add(channel)
@ -214,7 +223,11 @@ func (channel *Channel) Join(client *Client, key string) {
channel.members[client][ChannelOperator] = true 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.GetTopic(client)
channel.Names(client) channel.Names(client)
} }

View File

@ -45,6 +45,7 @@ type Client struct {
nickMaskString string // cache for nickmask string since it's used with lots of replies nickMaskString string // cache for nickmask string since it's used with lots of replies
quitTimer *time.Timer quitTimer *time.Timer
realname string realname string
accountName string
registered bool registered bool
server *Server server *Server
socket *Socket socket *Socket
@ -65,6 +66,7 @@ func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
flags: make(map[UserMode]bool), flags: make(map[UserMode]bool),
server: server, server: server,
socket: &socket, socket: &socket,
accountName: "*", // * is used until actual account name is set
nickString: "*", // * is used until actual nick is given nickString: "*", // * is used until actual nick is given
} }
if isTLS { if isTLS {

View File

@ -423,7 +423,7 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
client.username = Name("~" + msg.Params[0]) client.username = Name("~" + msg.Params[0])
client.updateNickMask() client.updateNickMask()
} }
if client.realname != "" { if client.realname == "" {
client.realname = msg.Params[3] client.realname = msg.Params[3]
} }