1
0
Fork 0
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:
Myned 2020-10-13 02:24:19 -04:00
commit 4e596095da
No known key found for this signature in database
GPG key ID: D42B2DAADE7D2AB5
3 changed files with 70 additions and 3 deletions

View file

@ -22,6 +22,7 @@ beautifulsoup4 = "*"
requests = "*"
html5lib = "*"
tldextract = "*"
selenium = "*"
[dev-packages]
lxml = "*"

61
src/cogs/weeb.py Normal file
View file

@ -0,0 +1,61 @@
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
import asyncio
import traceback as tb
from discord.ext import commands as cmds
from utils import utils as u
class Weeb(cmds.Cog):
def __init__(self, bot):
self.bot = bot
self.weebing = False
with open('id.json') as f:
self.id = int(f.readline())
print('LOADED : id.json')
if not self.weebing:
self.weebing = True
self.bot.loop.create_task(self.start())
print('STARTED : weebing')
async def refresh(self, browser, urls):
message = ''
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'
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)
if message:
await self.bot.get_user(self.id).send(message)
await self.bot.get_user(u.config['owner_id']).send('Message sent')
browser.quit()
self.weebing = False
await asyncio.sleep(60)
except Exception as e:
tb.print_exc()
await self.bot.get_user(u.config['owner_id']).send(f'! ERROR !\n\n{repr(e)}')

View file

@ -21,25 +21,30 @@ def get_prefix(bot, message):
return u.settings['prefixes'].get(message.guild.id, u.config['prefix'])
return u.config['prefix']
intents = d.Intents.default()
intents.members = True
bot = cmds.Bot(
intents=intents,
command_prefix=get_prefix,
self_bot=u.config['selfbot'],
description='Modufur - A booru bot with a side of management and automated tasking'
'\nMade by @Myned#3985')
'\nMade by @Myned#3985'
)
@bot.event
async def on_ready():
if not checks.ready:
from cogs import booru, info, management, owner, tools
from cogs import weeb, booru, info, management, owner, tools
for cog in (
tools.Utils(bot),
owner.Bot(bot),
management.Admin(bot),
info.Info(bot),
booru.MsG(bot)):
booru.MsG(bot),
weeb.Weeb(bot)):
bot.add_cog(cog)
u.cogs[type(cog).__name__] = cog
print(f'COG : {type(cog).__name__}')