Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure prefixcontext/suffixcontent shown for all lines in a multi-line message #483

Merged
merged 7 commits into from
Nov 1, 2022

Conversation

hloeung
Copy link
Collaborator

@hloeung hloeung commented Oct 16, 2022

With the new no splitting multi-line messages in PR #482, multi-line messages are displayed as:

|20:09 <hloeung> Test One
|20:09 <hloeung> Test Two
|20:09 <hloeung> Test Three [c9ouoenfkprajc6o96zdp9z87y]
|20:16 <hloeung> Test One
|20:16 <hloeung> Test Two
|20:16 <hloeung> Test Three (re @hloeung: Test One Test Two Test …) [↪c9ouoenfkprajc6o96zdp9z87y,ak8gwopx4jnqbjf5ipnrtifyrc]

Unfortunately, it means using tools such as grepping won't show all the lines as part of the message. This fixes that:

|20:48 <hloeung> Test One [↪c9ouoenfkprajc6o96zdp9z87y,6wfxbuie3ty8x84ya4fpj8cabr]
|20:48 <hloeung> Test Two [↪c9ouoenfkprajc6o96zdp9z87y,6wfxbuie3ty8x84ya4fpj8cabr]
|20:48 <hloeung> Test Three (re @hloeung: Test One Test Two Test …) [↪c9ouoenfkprajc6o96zdp9z87y,6wfxbuie3ty8x84ya4fpj8cabr]
|20:50 <hloeung> Test One [002->001]
|20:50 <hloeung> Test Two [003->001]
|20:50 <hloeung> Test Three (re @hloeung: Test One Test Two Test …) [004->001]
|20:51 <hloeung> Test One [005->001]
|20:51 <hloeung> Test Two [006->001]
|20:51 <hloeung> Test Three (re @hloeung: Test One Test Two Test …) [007->001]
|20:51 <hloeung> Test [008]
|20:51 <hloeung> @@008 test [↪008]
|20:51 <hloeung> [↪c9ouoenfkprajc6o96zdp9z87y,gcopf88mcif1zdhjyscikrtscw] Test One
|20:51 <hloeung> [↪c9ouoenfkprajc6o96zdp9z87y,gcopf88mcif1zdhjyscikrtscw] Test Two
|20:51 <hloeung> [↪c9ouoenfkprajc6o96zdp9z87y,gcopf88mcif1zdhjyscikrtscw] Test Three (re @hloeung: Test One Test Two Test …)
|20:52 <hloeung> [↪c9ouoenfkprajc6o96zdp9z87y] Test One
|20:52 <hloeung> [↪c9ouoenfkprajc6o96zdp9z87y] Test Two
|20:52 <hloeung> [↪c9ouoenfkprajc6o96zdp9z87y] Test Three (re @hloeung: Test One Test Two Test …)

@42wim
Copy link
Owner

42wim commented Oct 21, 2022

@hloeung can you look at the conflicts below (bridge/mattermost6/mattermost.go)?

@42wim 42wim added this to the 0.26.0 milestone Oct 21, 2022
@hloeung
Copy link
Collaborator Author

hloeung commented Oct 21, 2022

@42wim ok removed that block

@42wim
Copy link
Owner

42wim commented Oct 31, 2022

This is getting a bit too complex though :/

It doesn't seem to work correctly when using prefixcontext
A multiline message now shows this for me

21:56 <@wim> [001] this are multiple
21:56 <@wim> [002] lines
21:56 <@wim> [003] with
21:56 <@wim> [004] ```
21:56 <@wim> [005] codeblock
21:56 <@wim> [006]
21:56 <@wim> [007] ```
21:56 <@wim> [008] done

and only replying on @@008 works, no way to see that this is a multiline message.

with hidecontextmulti disabled it gives me this

22:28 <@wim> this are multiple
22:28 <@wim> lines
22:28 <@wim> with
22:28 <@wim> ```
22:28 <@wim> codeblock
22:28 <@wim> ```
22:28 <@wim> [001] done

(replying on @@001 works though)

while what I actually want is

22:28 <@wim> [001] this are multiple
22:28 <@wim> lines
22:28 <@wim> with
22:28 <@wim> ```
22:28 <@wim> codeblock
22:28 <@wim> ```
22:28 <@wim> done

Other comments on the changes:

  • I don't think its a good idea to remove the newline and 440 chars check from the MsgSpoofUser and Channel Spoof, those methods are responsible for writing to irc and should do those checks, it's not guaranteed that in the future only the handleDirectMessageEvent and handleChannelMessageEvent are the only ones using those methods
  • HideContextMulti as default false should be inverted, ShowContextMulti: false
  • Can we put the if showContext maybe in a separate method as it's the same thing repeated

@hloeung hloeung marked this pull request as draft November 1, 2022 02:51
@hloeung hloeung force-pushed the nomulti branch 2 times, most recently from 098cfef to b3ee30f Compare November 1, 2022 12:03
@hloeung hloeung marked this pull request as ready for review November 1, 2022 12:07
@hloeung
Copy link
Collaborator Author

hloeung commented Nov 1, 2022

@42wim , okay, try it out now!

I did some testing with all combinations I can think of.

|22:52 <hloeung> Testing
|22:52 <hloeung> [001] Test One
|22:52 <hloeung> [001] Test Two (space above)
|22:52 <hloeung> [001] Test Three
|22:52 <hloeung> [002] Test One
|22:52 <hloeung> Test Two (space above)
|22:52 <hloeung> Test Three
|22:53 <hloeung> [@@3pcmi4un7td5ups4oi7r3txjxe] Test One
|22:53 <hloeung> Test Two (space above)
|22:53 <hloeung> Test Three
|22:53 <hloeung> Test One
|22:53 <hloeung> Test Two (space above)
|22:53 <hloeung> Test Three [@@qowh4sewe7rtdcxzzn8o43mb1e]
|22:53 <hloeung> Test One
|22:53 <hloeung> Test Two (space above)
|22:53 <hloeung> Test Three (re @hloeung: Test One  Test Two (space …) [↪@@qowh4sewe7rtdcxzzn8o43mb1e]
|22:54 <hloeung> Test One
|22:54 <hloeung> Test Two (space above)
|22:54 <hloeung> Test Three (re @hloeung: Test One  Test Two (space …) [↪@@qowh4sewe7rtdcxzzn8o43mb1e,@@ko7b5wdkwpry78u1ugasb53jzc]
|22:54 <hloeung> Test One [↪@@qowh4sewe7rtdcxzzn8o43mb1e,@@iizy1uftnjnpuxaspq9gdw5wse]
|22:54 <hloeung> Test Two (space above) [↪@@qowh4sewe7rtdcxzzn8o43mb1e,@@iizy1uftnjnpuxaspq9gdw5wse]
|22:54 <hloeung> Test Three (re @hloeung: Test One  Test Two (space …) [↪@@qowh4sewe7rtdcxzzn8o43mb1e,@@iizy1uftnjnpuxaspq9gdw5wse]
|22:55 <hloeung> [↪@@qowh4sewe7rtdcxzzn8o43mb1e,@@3g597sjsu7nktbhueaayou1xbo] Test One
|22:55 <hloeung> [↪@@qowh4sewe7rtdcxzzn8o43mb1e,@@3g597sjsu7nktbhueaayou1xbo] Test Two (space above)
|22:55 <hloeung> [↪@@qowh4sewe7rtdcxzzn8o43mb1e,@@3g597sjsu7nktbhueaayou1xbo] Test Three (re @hloeung: Test One  Test Two (space …)
|22:55 <hloeung> [@@usxm55ixaintpci43a6eghz6kw] Test One
|22:55 <hloeung> [@@usxm55ixaintpci43a6eghz6kw] Test Two (space above)
|22:55 <hloeung> [@@usxm55ixaintpci43a6eghz6kw] Test Three

@42wim 42wim merged commit db8eb23 into 42wim:nomulti Nov 1, 2022
@42wim
Copy link
Owner

42wim commented Nov 1, 2022

Thanks a lot for your work / time on this!

42wim added a commit that referenced this pull request Nov 1, 2022
* Do not split message on newlines

This fixes #480 and as a bonus
also fixes #426 as this is now
just 1 big message for irc

See also #483

* Check code block start on multiple lines

* Ensure prefixcontext/suffixcontent shown for all lines in a multi-line message (#483)

* Ensure prefixcontext/suffixcontent shown for all lines in a multi-line message

* Make showing context for multi-line messages configurable

* Fix to handle empty lines now that we're splitting elsewhere

* Restore changes to MsgSpoofUser() and Spoof() per review

* Allow overriding max. line length

* Fix to correctly add message thread context

* Refactor and remove duplicate code per review

Co-authored-by: Haw Loeung <haw.loeung@canonical.com>
@hloeung hloeung deleted the nomulti branch November 1, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants