forked from External/ergo
implement draft/pre-away (#2044)
* implement draft/pre-away * clean up some subtleties in auto-away aggregation. * consistently apply auto-away only to always-on * `AWAY *` should not produce user-visible changes wherever possible
This commit is contained in:
parent
12f7796933
commit
1da11ae8ae
8 changed files with 63 additions and 38 deletions
|
|
@ -447,32 +447,34 @@ func authScramHandler(server *Server, client *Client, session *Session, value []
|
|||
|
||||
// AWAY [<message>]
|
||||
func awayHandler(server *Server, client *Client, msg ircmsg.Message, rb *ResponseBuffer) bool {
|
||||
var isAway bool
|
||||
// #1996: `AWAY :` is treated the same as `AWAY`
|
||||
var awayMessage string
|
||||
if len(msg.Params) > 0 {
|
||||
awayMessage = msg.Params[0]
|
||||
awayMessage = ircutils.TruncateUTF8Safe(awayMessage, server.Config().Limits.AwayLen)
|
||||
}
|
||||
isAway = (awayMessage != "") // #1996
|
||||
|
||||
rb.session.SetAway(awayMessage)
|
||||
wasAway, nowAway := rb.session.SetAway(awayMessage)
|
||||
|
||||
if isAway {
|
||||
if nowAway != "" {
|
||||
rb.Add(nil, server.name, RPL_NOWAWAY, client.nick, client.t("You have been marked as being away"))
|
||||
} else {
|
||||
rb.Add(nil, server.name, RPL_UNAWAY, client.nick, client.t("You are no longer marked as being away"))
|
||||
}
|
||||
|
||||
dispatchAwayNotify(client, isAway, awayMessage)
|
||||
if client.registered && wasAway != nowAway {
|
||||
dispatchAwayNotify(client, nowAway)
|
||||
} // else: we'll send it (if applicable) after reattach
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func dispatchAwayNotify(client *Client, isAway bool, awayMessage string) {
|
||||
func dispatchAwayNotify(client *Client, awayMessage string) {
|
||||
// dispatch away-notify
|
||||
details := client.Details()
|
||||
isBot := client.HasMode(modes.Bot)
|
||||
for session := range client.FriendsMonitors(caps.AwayNotify) {
|
||||
if isAway {
|
||||
if awayMessage != "" {
|
||||
session.sendFromClientInternal(false, time.Time{}, "", details.nickMask, details.accountName, isBot, nil, "AWAY", awayMessage)
|
||||
} else {
|
||||
session.sendFromClientInternal(false, time.Time{}, "", details.nickMask, details.accountName, isBot, nil, "AWAY")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue