3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00
This commit is contained in:
Shivaram Lingamneni 2020-07-17 01:55:13 -04:00
parent a99c893f9b
commit 93530ae397
5 changed files with 18 additions and 12 deletions

View File

@ -767,6 +767,7 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
modestr = fmt.Sprintf("+%v", givenMode) modestr = fmt.Sprintf("+%v", givenMode)
} }
isAway, awayMessage := client.Away()
for _, member := range channel.Members() { for _, member := range channel.Members() {
for _, session := range member.Sessions() { for _, session := range member.Sessions() {
if session == rb.session { if session == rb.session {
@ -783,6 +784,9 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
if givenMode != 0 { if givenMode != 0 {
session.Send(nil, client.server.name, "MODE", chname, modestr, details.nick) session.Send(nil, client.server.name, "MODE", chname, modestr, details.nick)
} }
if isAway && session.capabilities.Has(caps.AwayNotify) {
session.sendFromClientInternal(false, time.Time{}, "", details.nickMask, details.account, nil, "AWAY", awayMessage)
}
} }
} }
@ -1458,8 +1462,8 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuf
tnick := invitee.Nick() tnick := invitee.Nick()
rb.Add(nil, inviter.server.name, RPL_INVITING, cnick, tnick, chname) rb.Add(nil, inviter.server.name, RPL_INVITING, cnick, tnick, chname)
invitee.Send(nil, inviter.NickMaskString(), "INVITE", tnick, chname) invitee.Send(nil, inviter.NickMaskString(), "INVITE", tnick, chname)
if invitee.Away() { if away, awayMessage := invitee.Away(); away {
rb.Add(nil, inviter.server.name, RPL_AWAY, cnick, tnick, invitee.AwayMessage()) rb.Add(nil, inviter.server.name, RPL_AWAY, cnick, tnick, awayMessage)
} }
} }

View File

@ -185,9 +185,9 @@ func (client *Client) Hostname() string {
return client.hostname return client.hostname
} }
func (client *Client) Away() (result bool) { func (client *Client) Away() (result bool, message string) {
client.stateMutex.Lock() client.stateMutex.Lock()
result = client.away result, message = client.away, client.awayMessage
client.stateMutex.Unlock() client.stateMutex.Unlock()
return return
} }

View File

@ -2122,9 +2122,11 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
rb.AddSplitMessageFromClient(nickMaskString, accountName, tagsToSend, command, tnick, message) rb.AddSplitMessageFromClient(nickMaskString, accountName, tagsToSend, command, tnick, message)
} }
} }
if histType != history.Notice && user.Away() { if histType != history.Notice {
//TODO(dan): possibly implement cooldown of away notifications to users //TODO(dan): possibly implement cooldown of away notifications to users
rb.Add(nil, server.name, RPL_AWAY, client.Nick(), tnick, user.AwayMessage()) if away, awayMessage := user.Away(); away {
rb.Add(nil, server.name, RPL_AWAY, client.Nick(), tnick, awayMessage)
}
} }
config := server.Config() config := server.Config()
@ -2742,7 +2744,7 @@ func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *
if target.HasMode(modes.Operator) { if target.HasMode(modes.Operator) {
isOper = "*" isOper = "*"
} }
if target.Away() { if away, _ := target.Away(); away {
isAway = "-" isAway = "-"
} else { } else {
isAway = "+" isAway = "+"
@ -2893,7 +2895,7 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response
} }
if fields.Has('f') { // "flags" (away + oper state + channel status prefix + bot) if fields.Has('f') { // "flags" (away + oper state + channel status prefix + bot)
var flags strings.Builder var flags strings.Builder
if target.Away() { if away, _ := target.Away(); away {
flags.WriteRune('G') // Gone flags.WriteRune('G') // Gone
} else { } else {
flags.WriteRune('H') // Here flags.WriteRune('H') // Here

View File

@ -110,9 +110,9 @@ func sendRoleplayMessage(server *Server, client *Client, source string, targetSt
for _, session := range user.Sessions() { for _, session := range user.Sessions() {
session.sendSplitMsgFromClientInternal(false, source, "", nil, "PRIVMSG", tnick, splitMessage) session.sendSplitMsgFromClientInternal(false, source, "", nil, "PRIVMSG", tnick, splitMessage)
} }
if user.Away() { if away, awayMessage := user.Away(); away {
//TODO(dan): possibly implement cooldown of away notifications to users //TODO(dan): possibly implement cooldown of away notifications to users
rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, user.AwayMessage()) rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, awayMessage)
} }
} }
} }

View File

@ -436,8 +436,8 @@ func (client *Client) getWhoisOf(target *Client, rb *ResponseBuffer) {
} }
} }
rb.Add(nil, client.server.name, RPL_WHOISIDLE, cnick, tnick, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), client.t("seconds idle, signon time")) rb.Add(nil, client.server.name, RPL_WHOISIDLE, cnick, tnick, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), client.t("seconds idle, signon time"))
if target.Away() { if away, awayMessage := target.Away(); away {
rb.Add(nil, client.server.name, RPL_AWAY, cnick, tnick, target.AwayMessage()) rb.Add(nil, client.server.name, RPL_AWAY, cnick, tnick, awayMessage)
} }
} }