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

Suggestion: modular browser choice #6

Open
pedrorq opened this issue May 18, 2021 · 1 comment
Open

Suggestion: modular browser choice #6

pedrorq opened this issue May 18, 2021 · 1 comment

Comments

@pedrorq
Copy link

pedrorq commented May 18, 2021

I modified my local open.py to make it more modular & easier to pick a browser to use

Declare a new variable:

# Browser path
mybrowser = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

And then the main loop just calls this new variable

# Check for keywords and blacklisted words in message urls and open browser if conditions are met
async def check_urls(urls, channel_name):
for url in urls:
if any(x in url.lower() for x in keywords) and all(x not in url.lower() for x in blacklist):
# Check if url contains partalert.net. If true, direct amazon link will be built.
if "partalert.net" in url:
amazon_url = get_amazon_url(url)
# Enter path to your browser
webbrowser.get( mybrowser ).open(amazon_url)
print_time(f'Link opened from #{channel_name}: {amazon_url}')
else:
# Enter path to your browser
webbrowser.get( mybrowser ).open(url)
print_time(f'Link opened from #{channel_name}: {url}')
if playBellSound:
winsound.PlaySound('bell.wav', winsound.SND_FILENAME)

This way only the variable on top needs to be modified when deciding to use Chrome or Edge or Firefox etc

@Smidelis
Copy link
Owner

Good idea, will implement it the next time i am running the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants