Browse Source

accounts: Add account-tag capability

tags/v0.1.0
Daniel Oaks 7 years ago
parent
commit
754b74c21c
4 changed files with 20 additions and 4 deletions
  1. 1
    1
      CHANGELOG.md
  2. 2
    0
      irc/capability.go
  3. 2
    3
      irc/channel.go
  4. 15
    0
      irc/client.go

+ 1
- 1
CHANGELOG.md View File

@@ -21,7 +21,7 @@ Initial release of Oragono!
21 21
 * Added ability to parse complex mode change syntax commonly used these days (i.e. `+h-ov dan dan dan`).
22 22
 * Added user mode for clients connected via TLS (`+Z`).
23 23
 * Added ability to register and login to accounts (with passphrase or certfp).
24
-* 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).
24
+* 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).
25 25
 
26 26
 ### Changed
27 27
 * Changed channel creator (`O`) privilege to founder/admin/halfops (`qah`) privileges.

+ 2
- 0
irc/capability.go View File

@@ -14,6 +14,7 @@ import (
14 14
 type Capability string
15 15
 
16 16
 const (
17
+	AccountTag      Capability = "account-tag"
17 18
 	ExtendedJoin    Capability = "extended-join"
18 19
 	MultiPrefix     Capability = "multi-prefix"
19 20
 	SASL            Capability = "sasl"
@@ -23,6 +24,7 @@ const (
23 24
 
24 25
 var (
25 26
 	SupportedCapabilities = CapabilitySet{
27
+		AccountTag:      true,
26 28
 		ExtendedJoin:    true,
27 29
 		MultiPrefix:     true,
28 30
 		SASL:            true,

+ 2
- 3
irc/channel.go View File

@@ -304,8 +304,7 @@ func (channel *Channel) PrivMsg(client *Client, message string) {
304 304
 		if member == client {
305 305
 			continue
306 306
 		}
307
-		//TODO(dan): use nickmask instead of nickString here lel
308
-		member.Send(nil, client.nickMaskString, "PRIVMSG", channel.nameString, message)
307
+		member.SendFromClient(client, nil, client.nickMaskString, "PRIVMSG", channel.nameString, message)
309 308
 	}
310 309
 }
311 310
 
@@ -452,7 +451,7 @@ func (channel *Channel) Notice(client *Client, message string) {
452 451
 		if member == client {
453 452
 			continue
454 453
 		}
455
-		member.Send(nil, client.nickMaskString, "NOTICE", channel.nameString, message)
454
+		member.SendFromClient(client, nil, client.nickMaskString, "NOTICE", channel.nameString, message)
456 455
 	}
457 456
 }
458 457
 

+ 15
- 0
irc/client.go View File

@@ -349,6 +349,21 @@ func (client *Client) destroy() {
349 349
 	}
350 350
 }
351 351
 
352
+// SendFromClient sends an IRC line coming from a specific client.
353
+// Adds account-tag to the line as well.
354
+func (client *Client) SendFromClient(from *Client, tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error {
355
+	// attach account-tag
356
+	if client.capabilities[AccountTag] && from.account != &NoAccount {
357
+		if tags == nil {
358
+			tags = ircmsg.MakeTags("account", from.account.Name)
359
+		} else {
360
+			(*tags)["account"] = ircmsg.MakeTagValue(from.account.Name)
361
+		}
362
+	}
363
+
364
+	return client.Send(tags, prefix, command, params...)
365
+}
366
+
352 367
 // Send sends an IRC line to the client.
353 368
 func (client *Client) Send(tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error {
354 369
 	// attach server-time

Loading…
Cancel
Save