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

Feature to remove links and usernames from messages #129

Closed
rijeshkumar opened this issue May 7, 2021 · 6 comments
Closed

Feature to remove links and usernames from messages #129

rijeshkumar opened this issue May 7, 2021 · 6 comments
Labels
enhancement New feature or request plugin

Comments

@rijeshkumar
Copy link

Please add a plugin for automatically detecting and removing any kind of links from messages

@rijeshkumar rijeshkumar added the enhancement New feature or request label May 7, 2021
@aahnik
Copy link
Owner

aahnik commented May 7, 2021

that's a good idea. but there are other features on the priority list. (I will touch this after other important things are done)

If you know python and a little bit of telethon library, you may try doing this

read more about plugins here :

@aahnik
Copy link
Owner

aahnik commented Jun 5, 2021

You can do this in many ways.

using regex

For this, you need to learn regex. Or use google search to find what you want.

  1. Use regex to match a pattern and blacklist it. (read filtering)
  2. Use regex to replace patterns like URLs or usernames with some other text (may be blank text, that means removed)
    (regex pattern can find URLs which start with http or https reliably. But in telegram just writing something.com is also a link. Writing a regex that will match that is difficult. It may match sentence endings with fullstop, and new line starting without a space.) read text replacement

format

You can change the text format to "code". Thus all links will be unclickable. read formatting

@rijeshkumar
Copy link
Author

rijeshkumar commented Jun 6, 2021

Thanks for regex support. I created a regex pattern to find URLs starting with https:// or http://. Sharing it for those who need it.
(https|http)(://)\\S+
Above regex can find every lines starting with https:// or http// and select that line till a space come.

(Note: double back slash before S needed only if u use yaml. In other cases single back slash is enough

@aahnik
Copy link
Owner

aahnik commented Jun 6, 2021

(Note: double back slash before S needed only if u use yaml. In other cases single back slash is enough

Yup! Inside yaml, you need to escape the \, otherwise, yaml bura man jayga.

@aahnik aahnik closed this as completed Jun 6, 2021
@aahnik
Copy link
Owner

aahnik commented Jun 11, 2021

To convert all @username to username just do

  replace:
    text:
      "\\s+(@(\\w+))\\s*": " \\2 "
    regex: true

(exception: this pattern will not apply to the first word of message if that starts with @)

image
image

@cleanerspam
Copy link

Can anyone provide a regex to remove everyhting from caption except those lines that are ending with .mkv or .mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin
Projects
None yet
Development

No branches or pull requests

3 participants