mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 13:02:38 +00:00
Add additional website to notify
This commit is contained in:
parent
94ea52a00a
commit
84d1e0d878
1 changed files with 33 additions and 14 deletions
|
@ -22,15 +22,36 @@ class Weeb(cmds.Cog):
|
|||
self.bot.loop.create_task(self.start())
|
||||
print('STARTED : weebing')
|
||||
|
||||
async def refresh(self, browser, urls):
|
||||
async def refresh_switchmod(self, browser):
|
||||
message = ''
|
||||
urls = {
|
||||
'Novelties': 'https://switchmod.net/collections/ended-gbs/products/gmk-metaverse-2?variant=31671816880208',
|
||||
'Royal': 'https://switchmod.net/collections/ended-gbs/products/gmk-metaverse-2?variant=31671816945744'
|
||||
}
|
||||
|
||||
for item, url in urls.items():
|
||||
browser.get(url)
|
||||
status = browser.find_elements_by_css_selector('#addToCartText-product-template')[0].text
|
||||
|
||||
if status != 'SOLD OUT':
|
||||
message += f'{item} is in stock!\n{url}\n'
|
||||
message += f'{item} is in stock at Switchmod!\n<{url}>\n'
|
||||
|
||||
await asyncio.sleep(5)
|
||||
|
||||
return message
|
||||
|
||||
async def refresh_deskhero(self, browser):
|
||||
message = ''
|
||||
url = 'https://www.deskhero.ca/products/gmk-metaverse-2'
|
||||
|
||||
browser.get(url)
|
||||
royal_soldout = browser.find_elements_by_css_selector('#data-product-option-1-1')[0].get_attribute('data-soldout')
|
||||
novelties_soldout = browser.find_elements_by_css_selector('#data-product-option-1-3')[0].get_attribute('data-soldout')
|
||||
|
||||
if royal_soldout != 'true':
|
||||
message += f'Royal is in stock at Deskhero!\n<{url}>\n'
|
||||
if novelties_soldout != 'true':
|
||||
message += f'Novelties is in stock at Deskhero!\n<{url}>\n'
|
||||
|
||||
return message
|
||||
|
||||
|
@ -39,17 +60,15 @@ class Weeb(cmds.Cog):
|
|||
opts = Options()
|
||||
opts.headless = True
|
||||
browser = Chrome(executable_path='/usr/bin/chromedriver', options=opts)
|
||||
urls = {
|
||||
'Novelties': 'https://switchmod.net/collections/ended-gbs/products/gmk-metaverse-2?variant=31671816880208',
|
||||
'Royal': 'https://switchmod.net/collections/ended-gbs/products/gmk-metaverse-2?variant=31671816945744'
|
||||
}
|
||||
|
||||
while self.weebing:
|
||||
message = await self.refresh(browser, urls)
|
||||
message = await self.refresh_switchmod(browser)
|
||||
await asyncio.sleep(5)
|
||||
message += await self.refresh_deskhero(browser)
|
||||
|
||||
if message:
|
||||
await self.bot.get_user(self.id).send(message)
|
||||
await self.bot.get_user(u.config['owner_id']).send('Message sent')
|
||||
await self.bot.get_user(u.config['owner_id']).send('Something is in stock. Restart to keep checking')
|
||||
|
||||
browser.quit()
|
||||
self.weebing = False
|
||||
|
|
Loading…
Reference in a new issue