42wim / matterircd

Connect to your mattermost or slack using your IRC-client of choice.
MIT License
294 stars 60 forks source link

Allow modifying or deleting last message and by Mattermost message ID #353

Closed hloeung closed 3 years ago

hloeung commented 3 years ago

Store the Mattermost message ID of the most recent message sent to channel. With that, we can use 'last' to modify or delete. e.g.

|21:15 Test |21:15 s//Update last test message |21:15 s//

Also add support for modifying messages using the Mattermost message ID. e.g.

|21:14 Test [@@o5ctj8u3qfgtxf5icisewtdyty] |21:14 s/o5ctj8u3qfgtxf5icisewtdyty/Update |21:14 Update (edited) [@@o5ctj8u3qfgtxf5icisewtdyty] |21:14 s/o5ctj8u3qfgtxf5icisewtdyty/ |21:14 Update (deleted) [@@o5ctj8u3qfgtxf5icisewtdyty]

axinojolais commented 3 years ago

Should there be any documentation update to go along with this change ?

hloeung commented 3 years ago

Should there be any documentation update to go along with this change ?

Updated docs with how to update/modify or delete.

axinojolais commented 3 years ago

Hello, will this be merged any time soon ? Thanks !

hloeung commented 3 years ago

@42wim, free to take a look at this one?

Thanks!

hloeung commented 3 years ago

That last commit is what @jetpackdanger saw with just PrefixContext/SuffixContext. Thought I'll bundle the fix with this PR, happy to separate it out if you want @42wim.

42wim commented 3 years ago

I'm testing this, but the s// or s//blah only works one time, then it stops working. You don't have this issue?

hloeung commented 3 years ago

I'm testing this, but the s// or s//blah only works one time, then it stops working. You don't have this issue?

@42wim, Ah sorry, 9a80c59 broke it. I've fixed it now.

hloeung commented 3 years ago
|01:54 <hloeung> Test from web UI [@@f4fc…]
|01:54 <hloeung> s/f4fck99awfgg98crxpturrzwdr/Modify post from web UI
|01:54 <hloeung> Modify post from web UI (edited) [@@f4fc…]
|01:55 <hloeung> Test new one
|01:55 <hloeung> s//Modify the last 'Test new one'
|01:55 <hloeung> Test
|01:55 <hloeung> s//
|01:55 <hloeung> Test
|01:55 <hloeung> s//Test update
|01:55 <hloeung> s//Test update again

Produces:

U58YvLLlvQ

hloeung commented 3 years ago

Also with matterircd generated message/thread IDs:

|02:07 <hloeung> Test from web UI [007]
|02:07 <hloeung> s/007/Update message from web UI
|02:07 <hloeung> Update message from web UI (edited) [007]
|02:07 <hloeung> s//Update again
|02:07 <hloeung> Update again (edited) [007]
|02:07 <hloeung> New message
|02:07 <hloeung> s//

(yes, it really is 2am here heh)

y4Pf0Nxewk

42wim commented 3 years ago

Looks a lot of change, but it's basically just early returns where possible. Thanks for this cool feature :)

hloeung commented 3 years ago

Looks a lot of change, but it's basically just early returns where possible. Thanks for this cool feature :)

Ah yes, they all seem good to me. I didn't want to make too many changes blowing out the diff. Thanks for reviewing, let me try convince github to commit those.

42wim commented 3 years ago

sorry, seems my suggestions broke it :(

hloeung commented 3 years ago

sorry, seems my suggestions broke it :(

All good, pushed up a fix. Built and am quickly testing :)

hloeung commented 3 years ago

LGTM

|02:48 -!- Irssi: Join to #haw-test was synced in 21 secs
|02:48 <hloeung> Test
|02:48 <hloeung> ... [@@51fo…]
|02:48 <hloeung> s//Update last
|02:48 <hloeung> s/51foucr9gffi3mditz61djb5rh/Update by msg ID
|02:48 <hloeung> Update by msg ID (edited) [@@51fo…]
|02:49 <hloeung> s//update last, this is @@51fo
|02:49 <hloeung> update last, this is @@51fo (edited) [@@51fo…]
|02:49 <hloeung> Test, will be deleted
|02:49 <hloeung> s//
|02:49 <hloeung> @@51foucr9gffi3mditz61djb5rh replying to thread
|02:49 <hloeung> s//Update reply to thread...

13QwO6sAZc

hloeung commented 3 years ago

View from my IRC client, irssi:

MPnoOZ8mVO

42wim commented 3 years ago

🎉

hloeung commented 3 years ago

View from my IRC client, irssi:

MPnoOZ8mVO

Oh FWIW, the shortened message IDs, that's with this irssi script which I just pushed to GitHub - https://github.com/hloeung/matterircd-complete (does message/thread ID tab completion, key binding for most recent message/thread IDs and more...)