clearyy / discord-link-opener

Automatically open browser tabs when links matching given constraints are sent in discord channels.
GNU General Public License v3.0
47 stars 28 forks source link

Link no open browser #6

Open devNostyle opened 3 years ago

devNostyle commented 3 years ago

Seems some issue, Using PYTHON 3.7.X

Almost work, msg coming like :

Opened https://partalert.net/product.html?v=51421546#asin=B08KHKDTSJ&price=%E2%82%AC1%2C364.00&smid=A11IL2PNWYJU7H&tag=partalertit-21&timestamp=20%3A17+UTC+%2826.3.2021%29&title=Gigabyte+GeForce+RTX+3090+TURBO+-+Scheda+grafica+da+24+GB&tld=.it
€1,364.00 | Gigabyte GeForce RTX 3090 TURBO - Scheda grafica da 24 GB | <@&790173911127556126> <@&790178382800486402>

but chrome not open link ... hwo fix this ? or how try use this script on firefox ? im type pip install etc.

mmotti commented 3 years ago

@devNostyle I just had this issue.

The script has a hardcoded directory which assumes that the user is running a 32-bit version of Chrome installed to the program files directory.

Find out where your chrome directory is and modify the code accordingly.. eg mine is webbrowser.get("C:/Program Files/Google/Chrome/Application/chrome.exe %s").open(url)

devNostyle commented 3 years ago

@devNostyle I just had this issue.

The script has a hardcoded directory which assumes that the user is running a 32-bit version of Chrome installed to the program files directory.

Find out where your chrome directory is and modify the code accordingly.. eg mine is webbrowser.get("C:/Program Files/Google/Chrome/Application/chrome.exe %s").open(url)

not help ... hmm rly idk how fix them.

Stifl commented 3 years ago

@devNostyle I just had this issue.

The script has a hardcoded directory which assumes that the user is running a 32-bit version of Chrome installed to the program files directory.

Find out where your chrome directory is and modify the code accordingly.. eg mine is webbrowser.get("C:/Program Files/Google/Chrome/Application/chrome.exe %s").open(url)

Already tried this solution too and it still doesn't work.

Diken081 commented 3 years ago

It worked for me with chrome (64bit) with the following 2 lines:

chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
webbrowser.get(chrome_path).open(url)

or Firefox:

webbrowser.register('firefox', None, webbrowser.GenericBrowser('C:\Program Files\Mozilla Firefox\firefox.exe'))
webbrowser.get('firefox').open(url)

But the URL identifier code seems to be corrupt. It does not find the Amazon Associate URL in a message and sends me to an empty website with C:/Users.../Amazon Associate.

In CMD it shows me the correct URL followed by message title and channel ID: Opened https:// ...', message title | <@&CHANNEL ID>

with the following lines:

    else:
        if message.channel.id in channels:
            if message.embeds:
                for embed in message.embeds:
                    toembed = embed.to_dict()
                    if str(toembed['type']).lower() != 'link':
                        urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',toembed['title'])
                        if urls:
                            await check_urls(urls)
                        try:
                            urls2 = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',toembed['description'])
                            if urls2:
                                await check_urls(urls2)
                        except:
                            pass
                        try:
                            for field in toembed['fields']:
                                urls3 = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',str(field))
                                if urls3:
                                    await check_urls(urls3)
                        except:
                            pass
            if message.content != '':
                print(message.content)
                urls4 = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+',message.content)
                if urls4:
                    await check_urls(urls4)

client.run(token,bot=False)

But in the browser I get: C:/Users.../Amazon Associate.

New messages after this come without the Opened https:// and only title + Channel ID in CMD