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

accounts: Add account-tag capability

This commit is contained in:
Daniel Oaks 2016-09-12 11:25:31 +10:00
parent c2aa31001a
commit 754b74c21c
4 changed files with 20 additions and 4 deletions

View File

@ -21,7 +21,7 @@ Initial release of Oragono!
* Added ability to parse complex mode change syntax commonly used these days (i.e. `+h-ov dan dan dan`). * Added ability to parse complex mode change syntax commonly used these days (i.e. `+h-ov dan dan dan`).
* Added user mode for clients connected via TLS (`+Z`). * Added user mode for clients connected via TLS (`+Z`).
* Added ability to register and login to accounts (with passphrase or certfp). * Added ability to register and login to accounts (with passphrase or certfp).
* Added support for IRCv3 capabilities [`extended-join`](http://ircv3.net/specs/extensions/extended-join-3.1.html), [`sasl`](http://ircv3.net/specs/extensions/sasl-3.1.html), [`server-time`](http://ircv3.net/specs/extensions/server-time-3.2.html), and [`userhost-in-names`](http://ircv3.net/specs/extensions/userhost-in-names-3.2.html). * Added support for IRCv3 capabilities [`account-tag`](http://ircv3.net/specs/extensions/account-tag-3.2.html), [`extended-join`](http://ircv3.net/specs/extensions/extended-join-3.1.html), [`sasl`](http://ircv3.net/specs/extensions/sasl-3.1.html), [`server-time`](http://ircv3.net/specs/extensions/server-time-3.2.html), and [`userhost-in-names`](http://ircv3.net/specs/extensions/userhost-in-names-3.2.html).
### Changed ### Changed
* Changed channel creator (`O`) privilege to founder/admin/halfops (`qah`) privileges. * Changed channel creator (`O`) privilege to founder/admin/halfops (`qah`) privileges.

View File

@ -14,6 +14,7 @@ import (
type Capability string type Capability string
const ( const (
AccountTag Capability = "account-tag"
ExtendedJoin Capability = "extended-join" ExtendedJoin Capability = "extended-join"
MultiPrefix Capability = "multi-prefix" MultiPrefix Capability = "multi-prefix"
SASL Capability = "sasl" SASL Capability = "sasl"
@ -23,6 +24,7 @@ const (
var ( var (
SupportedCapabilities = CapabilitySet{ SupportedCapabilities = CapabilitySet{
AccountTag: true,
ExtendedJoin: true, ExtendedJoin: true,
MultiPrefix: true, MultiPrefix: true,
SASL: true, SASL: true,

View File

@ -304,8 +304,7 @@ func (channel *Channel) PrivMsg(client *Client, message string) {
if member == client { if member == client {
continue continue
} }
//TODO(dan): use nickmask instead of nickString here lel member.SendFromClient(client, nil, client.nickMaskString, "PRIVMSG", channel.nameString, message)
member.Send(nil, client.nickMaskString, "PRIVMSG", channel.nameString, message)
} }
} }
@ -452,7 +451,7 @@ func (channel *Channel) Notice(client *Client, message string) {
if member == client { if member == client {
continue continue
} }
member.Send(nil, client.nickMaskString, "NOTICE", channel.nameString, message) member.SendFromClient(client, nil, client.nickMaskString, "NOTICE", channel.nameString, message)
} }
} }

View File

@ -349,6 +349,21 @@ func (client *Client) destroy() {
} }
} }
// SendFromClient sends an IRC line coming from a specific client.
// Adds account-tag to the line as well.
func (client *Client) SendFromClient(from *Client, tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error {
// attach account-tag
if client.capabilities[AccountTag] && from.account != &NoAccount {
if tags == nil {
tags = ircmsg.MakeTags("account", from.account.Name)
} else {
(*tags)["account"] = ircmsg.MakeTagValue(from.account.Name)
}
}
return client.Send(tags, prefix, command, params...)
}
// Send sends an IRC line to the client. // Send sends an IRC line to the client.
func (client *Client) Send(tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error { func (client *Client) Send(tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error {
// attach server-time // attach server-time