mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 14:27:27 +00:00
Merge branch 'dev'
This commit is contained in:
commit
f9655e7f97
1 changed files with 33 additions and 14 deletions
|
@ -22,34 +22,53 @@ class Weeb(cmds.Cog):
|
|||
self.bot.loop.create_task(self.start())
|
||||
print('STARTED : weebing')
|
||||
|
||||
async def refresh(self, browser, urls):
|
||||
message = ''
|
||||
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
|
||||
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'
|
||||
if status != 'SOLD OUT':
|
||||
message += f'{item} is in stock at Switchmod!\n<{url}>\n'
|
||||
|
||||
return message
|
||||
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
|
||||
|
||||
async def start(self):
|
||||
try:
|
||||
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