~taiite/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2

[PATCH senpai] Merge MODE messages

Details
Message ID
<20211124170354.26957-1-delthas@dille.cc>
DKIM signature
pass
Download raw message
Patch: +6 -4
Also, fix an issue where mode strings only displayed the first
parameter.
---
 app.go         | 3 ++-
 irc/session.go | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/app.go b/app.go
index 00c31d2..f50f8bd 100644
--- a/app.go
+++ b/app.go
@@ -1009,12 +1009,13 @@ func (app *App) formatEvent(ev irc.Event) ui.Line {
			Body:      ui.Styled(body, tcell.StyleDefault.Foreground(tcell.ColorGray)),
		}
	case irc.ModeChangeEvent:
		body := fmt.Sprintf("Mode change: %s", ev.Mode)
		body := fmt.Sprintf("[%s]", ev.Mode)
		return ui.Line{
			At:        ev.Time,
			Head:      "--",
			HeadColor: tcell.ColorGray,
			Body:      ui.Styled(body, tcell.StyleDefault.Foreground(tcell.ColorGray)),
			Mergeable: true,
		}
	default:
		return ui.Line{}
diff --git a/irc/session.go b/irc/session.go
index bbf01f6..ea852d7 100644
--- a/irc/session.go
+++ b/irc/session.go
@@ -927,10 +927,11 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
			}, nil
		}
	case "MODE":
		var channel, mode string
		if err := msg.ParseParams(&channel, &mode); err != nil {
		var channel string
		if err := msg.ParseParams(&channel, nil); err != nil {
			return nil, err
		}
		mode := strings.Join(msg.Params[1:], " ")

		if playback {
			return ModeChangeEvent{
@@ -943,7 +944,7 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
		channelCf := s.Casemap(channel)

		if c, ok := s.channels[channelCf]; ok {
			modeChanges, err := ParseChannelMode(mode, msg.Params[2:], s.chanmodes, s.prefixModes)
			modeChanges, err := ParseChannelMode(msg.Params[1], msg.Params[2:], s.chanmodes, s.prefixModes)
			if err != nil {
				return nil, err
			}

base-commit: b813210eb6b7a50607985a14f969e33914ae0956
-- 
2.17.1
Details
Message ID
<fd022f4b-df1b-fc3b-5b93-193668470075@hirtz.pm>
In-Reply-To
<20211124170354.26957-1-delthas@dille.cc> (view parent)
DKIM signature
pass
Download raw message
On 24/11/2021 18:03, delthas wrote:
> Also, fix an issue where mode strings only displayed the first
> parameter.
> ---
>   app.go         | 3 ++-
>   irc/session.go | 7 ++++---
>   2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/app.go b/app.go
> index 00c31d2..f50f8bd 100644
> --- a/app.go
> +++ b/app.go
> @@ -1009,12 +1009,13 @@ func (app *App) formatEvent(ev irc.Event) ui.Line {
>   			Body:      ui.Styled(body, tcell.StyleDefault.Foreground(tcell.ColorGray)),
>   		}
>   	case irc.ModeChangeEvent:
> -		body := fmt.Sprintf("Mode change: %s", ev.Mode)
> +		body := fmt.Sprintf("[%s]", ev.Mode)
>   		return ui.Line{
>   			At:        ev.Time,
>   			Head:      "--",
>   			HeadColor: tcell.ColorGray,
>   			Body:      ui.Styled(body, tcell.StyleDefault.Foreground(tcell.ColorGray)),
> +			Mergeable: true,
>   		}
>   	default:
>   		return ui.Line{}
> diff --git a/irc/session.go b/irc/session.go
> index bbf01f6..ea852d7 100644
> --- a/irc/session.go
> +++ b/irc/session.go
> @@ -927,10 +927,11 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
>   			}, nil
>   		}
>   	case "MODE":
> -		var channel, mode string
> -		if err := msg.ParseParams(&channel, &mode); err != nil {
> +		var channel string
> +		if err := msg.ParseParams(&channel, nil); err != nil {
>   			return nil, err
>   		}
> +		mode := strings.Join(msg.Params[1:], " ")
>   
>   		if playback {
>   			return ModeChangeEvent{
> @@ -943,7 +944,7 @@ func (s *Session) handleMessageRegistered(msg Message, playback bool) (Event, er
>   		channelCf := s.Casemap(channel)
>   
>   		if c, ok := s.channels[channelCf]; ok {
> -			modeChanges, err := ParseChannelMode(mode, msg.Params[2:], s.chanmodes, s.prefixModes)
> +			modeChanges, err := ParseChannelMode(msg.Params[1], msg.Params[2:], s.chanmodes, s.prefixModes)
>   			if err != nil {
>   				return nil, err
>   			}
> 
> base-commit: b813210eb6b7a50607985a14f969e33914ae0956
> 
Details
Message ID
<16755a17-679c-65ac-3e15-1ae59fa51744@hirtz.pm>
In-Reply-To
<20211124170354.26957-1-delthas@dille.cc> (view parent)
DKIM signature
pass
Download raw message
Pushed
Reply to thread Export thread (mbox)