From 7ce396931cff32558112c65e1f9c93aacc5c7a1f Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Fri, 5 Feb 2021 13:07:39 -0500 Subject: [PATCH] fix #1516 CS OP should regrant one's stored amode --- irc/chanserv.go | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/irc/chanserv.go b/irc/chanserv.go index d322e343..47e56618 100644 --- a/irc/chanserv.go +++ b/irc/chanserv.go @@ -288,10 +288,11 @@ func csOpHandler(service *ircService, server *Server, client *Client, command st return } channelName := channelInfo.Name() + founder := channelInfo.Founder() clientAccount := client.Account() - if clientAccount == "" || clientAccount != channelInfo.Founder() { - service.Notice(rb, client.t("Only the channel founder can do this")) + if clientAccount == "" { + service.Notice(rb, client.t("You're not logged into an account")) return } @@ -306,11 +307,26 @@ func csOpHandler(service *ircService, server *Server, client *Client, command st target = client } - // give them privs - givenMode := modes.ChannelOperator - if clientAccount == target.Account() { - givenMode = modes.ChannelFounder + var givenMode modes.Mode + if target == client { + if clientAccount == founder { + givenMode = modes.ChannelFounder + } else { + givenMode = channelInfo.getAmode(clientAccount) + if givenMode == modes.Mode(0) { + service.Notice(rb, client.t("You don't have any stored privileges on that channel")) + return + } + } + } else { + if clientAccount == founder { + givenMode = modes.ChannelOperator + } else { + service.Notice(rb, client.t("Only the channel founder can do this")) + return + } } + applied, change := channelInfo.applyModeToMember(client, modes.ModeChange{Mode: givenMode, Op: modes.Add,