Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gencapdefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
url="https://ircv3.net/specs/extensions/server-time-3.2.html",
standard="IRCv3",
),
CapDef(
identifier="SetName",
name="draft/setname",
url="https://github.com/ircv3/ircv3-specifications/pull/361",
standard="proposed IRCv3",
),
CapDef(
identifier="STS",
name="sts",
Expand Down
7 changes: 6 additions & 1 deletion irc/caps/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package caps

const (
// number of recognized capabilities:
numCapabs = 20
numCapabs = 21
// length of the uint64 array that represents the bitset:
bitsetLen = 1
)
Expand Down Expand Up @@ -85,6 +85,10 @@ const (
// https://ircv3.net/specs/extensions/server-time-3.2.html
ServerTime Capability = iota

// SetName is the proposed IRCv3 capability named "draft/setname":
// https://github.com/ircv3/ircv3-specifications/pull/361
SetName Capability = iota

// STS is the IRCv3 capability named "sts":
// https://ircv3.net/specs/extensions/sts.html
STS Capability = iota
Expand Down Expand Up @@ -115,6 +119,7 @@ var (
"draft/resume-0.3",
"sasl",
"server-time",
"draft/setname",
"sts",
"userhost-in-names",
}
Expand Down
4 changes: 4 additions & 0 deletions irc/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ func init() {
handler: sceneHandler,
minParams: 2,
},
"SETNAME": {
handler: setnameHandler,
minParams: 1,
},
"TAGMSG": {
handler: tagmsgHandler,
minParams: 1,
Expand Down
16 changes: 16 additions & 0 deletions irc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,22 @@ func sceneHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
return false
}

// SETNAME <realname>
func setnameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
realname := msg.Params[0]

client.stateMutex.Lock()
client.realname = realname
client.stateMutex.Unlock()

// alert friends
for friend := range client.Friends(caps.SetName) {
friend.SendFromClient("", client, nil, "SETNAME", realname)
}

return false
}

// TAGMSG <target>{,<target>}
func tagmsgHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
clientOnlyTags := utils.GetClientOnlyTags(msg.Tags)
Expand Down
5 changes: 5 additions & 0 deletions irc/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,11 @@ opers. For more specific information on mode characters, see the help for
text: `SCENE <target> <text to be sent>

The SCENE command is used to send a scene notification to the given target.`,
},
"setname": {
text: `SETNAME <realname>

The SETNAME command updates the realname to be the newly-given one.`,
},
"tagmsg": {
text: `@+client-only-tags TAGMSG <target>{,<target>}
Expand Down
2 changes: 1 addition & 1 deletion irc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (

// SupportedCapabilities are the caps we advertise.
// MaxLine, SASL and STS are set during server startup.
SupportedCapabilities = caps.NewSet(caps.AccountTag, caps.AccountNotify, caps.AwayNotify, caps.Batch, caps.CapNotify, caps.ChgHost, caps.EchoMessage, caps.ExtendedJoin, caps.InviteNotify, caps.LabeledResponse, caps.Languages, caps.MessageTags, caps.MultiPrefix, caps.Rename, caps.Resume, caps.ServerTime, caps.UserhostInNames)
SupportedCapabilities = caps.NewSet(caps.AccountTag, caps.AccountNotify, caps.AwayNotify, caps.Batch, caps.CapNotify, caps.ChgHost, caps.EchoMessage, caps.ExtendedJoin, caps.InviteNotify, caps.LabeledResponse, caps.Languages, caps.MessageTags, caps.MultiPrefix, caps.Rename, caps.Resume, caps.ServerTime, caps.SetName, caps.UserhostInNames)

// CapValues are the actual values we advertise to v3.2 clients.
// actual values are set during server startup.
Expand Down