Skip to content

Change on_message_edit - only show differences, highlighted in blue with hyperlink#646

Merged
scragly merged 11 commits into
masterfrom
message-edit-hyperlink
Nov 30, 2019
Merged

Change on_message_edit - only show differences, highlighted in blue with hyperlink#646
scragly merged 11 commits into
masterfrom
message-edit-hyperlink

Conversation

@ikuyarihS
Copy link
Copy Markdown
Contributor

@ikuyarihS ikuyarihS commented Nov 3, 2019

Closes #632

Example:

Before edit:

There's clearly an easier way to handle this particular data by not using a relational db, but with how much of it does work with one, I'm having trouble judging if that solution is fine, or needs other handling.

After edit:

There's clearly an easier way to handle this data by not using a relational db, but with how much of it does work extremely well with one, I'm having trouble judging if that solution is acceptable, or needs other handling.

Embed will then show this:
image

Using ternary to avoid if else
- Merged `before_response` and `after_response`.
- Only show the differences between `before.clean_content` and `after.clean_content`
- Included a `jump to message` link.
@ikuyarihS ikuyarihS added area: cogs a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 3 - low Low Priority labels Nov 3, 2019
... I think?
- A simple `http://.z` will show properly for PC client, but for android it completely broke -> changed to `http://o.hi` - minimum link to make discord think it's a link.
Comment thread bot/cogs/moderation/modlog.py
Comment thread bot/cogs/moderation/modlog.py Outdated
Following Mark's reviews:
- The single `if` inside the `else` can be merged with its `else` - this will reduce the level of complexity and indentation.
- Changed from style
```py
new = ('hello'
       'world')
```
    to
```py
new = (
    'hello'
    'world'
)
```
    to be more consistent with the rest of the code
@MarkKoz
Copy link
Copy Markdown
Contributor

MarkKoz commented Nov 8, 2019

This doesn't work quite well in this case:

bild

Is this some obvious bug somewhere or just an inaccuracy we have to live with using difflib (in that case, would another library/approach be more accurate)?

@ikuyarihS
Copy link
Copy Markdown
Contributor Author

It's more of a logic bug, since I'm using str.replace() and the deleted word has a length of 1, chances are it will hyperlink more than just one. I'll take a look, if I remember correctly difflib can return the index as well.

Comment thread bot/cogs/moderation/modlog.py Outdated
@ikuyarihS ikuyarihS requested a review from scragly November 17, 2019 06:38
12pm added a commit to ddnet/ddnet-discordbot that referenced this pull request Nov 20, 2019
@lemonsaurus
Copy link
Copy Markdown
Contributor

I love this idea, very creative.

Comment thread bot/cogs/moderation/modlog.py Outdated
@scragly scragly merged commit 17c6bd9 into master Nov 30, 2019
@scragly scragly deleted the message-edit-hyperlink branch November 30, 2019 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 3 - low Low Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Showing what changed from on_message_edit

4 participants