From 51465b4a3aaceaaf986b47483a7e40c93f7b7e6e Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 28 Apr 2019 15:10:03 -0400 Subject: [PATCH] strip out the +a away mode --- docs/MANUAL.md | 4 ---- irc/channel.go | 2 +- irc/client.go | 1 + irc/getters.go | 16 ++++++++++++++++ irc/handlers.go | 7 +++---- irc/modes/modes.go | 3 +-- irc/roleplay.go | 2 +- irc/server.go | 2 +- 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 1422dd1e..d8c246e2 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -315,10 +315,6 @@ In this section, we give an overview of the modes Oragono supports. These are the modes which can be set on you when you're connected. -### +a - Away - -If this mode is set, you're marked as 'away'. To set and unset this mode, you use the `/AWAY` command. - ### +i - Invisible If this mode is set, you're marked as 'invisible'. This means that your channels won't be shown when users `/WHOIS` you (except for IRC operators, they can see all the channels you're in). diff --git a/irc/channel.go b/irc/channel.go index 33bfc23d..2a145709 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -1166,7 +1166,7 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuf tnick := invitee.Nick() rb.Add(nil, inviter.server.name, RPL_INVITING, cnick, tnick, chname) invitee.Send(nil, inviter.NickMaskString(), "INVITE", tnick, chname) - if invitee.HasMode(modes.Away) { + if invitee.Away() { rb.Add(nil, inviter.server.name, RPL_AWAY, cnick, tnick, invitee.AwayMessage()) } } diff --git a/irc/client.go b/irc/client.go index 48a84183..e7cb33a1 100644 --- a/irc/client.go +++ b/irc/client.go @@ -49,6 +49,7 @@ type Client struct { account string accountName string // display name of the account: uncasefolded, '*' if not logged in atime time.Time + away bool awayMessage string certfp string channels ChannelSet diff --git a/irc/getters.go b/irc/getters.go index e1ea43c2..ac3e5124 100644 --- a/irc/getters.go +++ b/irc/getters.go @@ -141,6 +141,22 @@ func (client *Client) Realname() string { return client.realname } +func (client *Client) Away() (result bool) { + client.stateMutex.Lock() + result = client.away + client.stateMutex.Unlock() + return +} + +func (client *Client) SetAway(away bool, awayMessage string) (changed bool) { + client.stateMutex.Lock() + changed = away != client.away + client.away = away + client.awayMessage = awayMessage + client.stateMutex.Unlock() + return +} + // uniqueIdentifiers returns the strings for which the server enforces per-client // uniqueness/ownership; no two clients can have colliding casefolded nicks or // skeletons. diff --git a/irc/handlers.go b/irc/handlers.go index 77a859f0..c2c61415 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -466,8 +466,7 @@ func awayHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp } } - client.SetMode(modes.Away, isAway) - client.SetAwayMessage(awayMessage) + client.SetAway(isAway, awayMessage) if isAway { rb.Add(nil, server.name, RPL_NOWAWAY, client.nick, client.t("You have been marked as being away")) @@ -2030,7 +2029,7 @@ func messageHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R session.sendSplitMsgFromClientInternal(false, now, nickMaskString, accountName, clientOnlyTags, msg.Command, tnick, splitMsg) } } - if histType != history.Notice && user.HasMode(modes.Away) { + if histType != history.Notice && user.Away() { //TODO(dan): possibly implement cooldown of away notifications to users rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, user.AwayMessage()) } @@ -2499,7 +2498,7 @@ func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb * if target.HasMode(modes.Operator) { isOper = "*" } - if target.HasMode(modes.Away) { + if target.Away() { isAway = "-" } else { isAway = "+" diff --git a/irc/modes/modes.go b/irc/modes/modes.go index fd433a11..0aca61c6 100644 --- a/irc/modes/modes.go +++ b/irc/modes/modes.go @@ -15,7 +15,7 @@ import ( var ( // SupportedUserModes are the user modes that we actually support (modifying). SupportedUserModes = Modes{ - Away, Bot, Invisible, Operator, RegisteredOnly, ServerNotice, UserRoleplaying, + Bot, Invisible, Operator, RegisteredOnly, ServerNotice, UserRoleplaying, } // SupportedChannelModes are the channel modes that we support. @@ -107,7 +107,6 @@ func (modes Modes) String() string { // User Modes const ( - Away Mode = 'a' Bot Mode = 'B' Invisible Mode = 'i' LocalOperator Mode = 'O' diff --git a/irc/roleplay.go b/irc/roleplay.go index 9dd256b6..2a419cbe 100644 --- a/irc/roleplay.go +++ b/irc/roleplay.go @@ -75,7 +75,7 @@ func sendRoleplayMessage(server *Server, client *Client, source string, targetSt if rb.session.capabilities.Has(caps.EchoMessage) { rb.Add(nil, source, "PRIVMSG", tnick, message) } - if user.HasMode(modes.Away) { + if user.Away() { //TODO(dan): possibly implement cooldown of away notifications to users rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, user.AwayMessage()) } diff --git a/irc/server.go b/irc/server.go index 27f8952e..fc628098 100644 --- a/irc/server.go +++ b/irc/server.go @@ -548,7 +548,7 @@ func (target *Client) rplWhoReply(channel *Channel, client *Client, rb *Response channelName := "*" flags := "" - if client.HasMode(modes.Away) { + if client.Away() { flags = "G" } else { flags = "H"