discord-link-opener
discord-link-opener copied to clipboard
# Issue
if a link has "#" in it, that links doesnt work correctly.
change the regex on lines 64 and 70 to "(?:(?:https?|ftp)://)?[\w/-?=%.#&+]+.[\w/-?=%.#&+]+"
Better, but now it cuts links on "-"
"(?:(?:https?|ftp)://)?[\w/-?=%.#&+-]+.[\w/-?=%.#&+-]+" would fix this I think
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?
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']
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 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):
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:
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')
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