discord-link-opener icon indicating copy to clipboard operation
discord-link-opener copied to clipboard

# Issue

Open StarLordRammi opened this issue 4 years ago • 9 comments

if a link has "#" in it, that links doesnt work correctly.

StarLordRammi avatar Mar 01 '21 03:03 StarLordRammi

change the regex on lines 64 and 70 to "(?:(?:https?|ftp)://)?[\w/-?=%.#&+]+.[\w/-?=%.#&+]+"

ryanthom139 avatar Mar 01 '21 07:03 ryanthom139

Better, but now it cuts links on "-"

"(?:(?:https?|ftp)://)?[\w/-?=%.#&+-]+.[\w/-?=%.#&+-]+" would fix this I think

pedrorq avatar Mar 02 '21 18:03 pedrorq

that worked, thank you. instead of making new thread, i wanted to ask if its possible to add permanenet keywords? or load them form a file instead of typing them everytime when the script is ran?

StarLordRammi avatar Mar 04 '21 05:03 StarLordRammi

You should be able to replace

keywords = list(map(str,input("Enter keywords seperated by space: ").split()))

with

keywords = ['keyword1','keyword2','keyword 3 4 5']

pedrorq avatar Mar 04 '21 14:03 pedrorq

You should be able to replace

keywords = list(map(str,input("Enter keywords seperated by space: ").split()))

with

keywords = ['keyword1','keyword2','keyword 3 4 5']

thanks again. what about if you dont want any blocklist and wanna skip it?

StarLordRammi avatar Apr 08 '21 22:04 StarLordRammi

You should be able to replace keywords = list(map(str,input("Enter keywords seperated by space: ").split())) with keywords = ['keyword1','keyword2','keyword 3 4 5']

thanks again. what about if you dont want any blocklist and wanna skip it?

You can just remove this line:

blacklist = list(map(str,input("Enter blacklisted keywords seperated by space: ").split()))

And then replace

if any(x in url.lower() for x in keywords) and all(x not in url.lower() for x in blacklist):

with

if any(x in url.lower() for x in keywords):

pedrorq avatar Apr 09 '21 08:04 pedrorq

getting this error

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\xxx\Desktop\open.py", line 54, in on_message
    if len(blacklist) > 0:

StarLordRammi avatar Apr 10 '21 11:04 StarLordRammi

You should be able to replace keywords = list(map(str,input("Enter keywords seperated by space: ").split())) with keywords = ['keyword1','keyword2','keyword 3 4 5']

thanks again. what about if you dont want any blocklist and wanna skip it?

You can just remove this line:

blacklist = list(map(str,input("Enter blacklisted keywords seperated by space: ").split()))

And then replace

if any(x in url.lower() for x in keywords) and all(x not in url.lower() for x in blacklist):

with

if any(x in url.lower() for x in keywords):

the following also needed removing

if len(blacklist) > 0: print('Ignoring keywords {}.\n'.format(', '.join(blacklist))) else: print('No keywords currently blacklisted.\n')

StarLordRammi avatar Apr 12 '21 11:04 StarLordRammi

Better, but now it cuts links on "-"

"(?:(?:https?|ftp)://)?[\w/-?=%.#&+-]+.[\w/-?=%.#&+-]+" would fix this I think

this does not open the following link correctly: https://www.cclonline.com/product/336566/ZT-A30800F-10P/Graphics-Cards/ZOTAC-GAMING-GeForce-RTX-3080-AMP-Holo-10GB-Graphics-Card/VGA5974/

above links opens as https://www.cclonline.com/product/336566/ZT-A30800F-10P/ and that gives page not found error

StarLordRammi avatar Apr 13 '21 09:04 StarLordRammi