added some broken functions
This commit is contained in:
30
main.py
30
main.py
@@ -11,12 +11,13 @@ import discord
|
||||
from discord.ext import commands
|
||||
|
||||
#objs
|
||||
options = Options()
|
||||
options = webdriver.FirefoxOptions()
|
||||
intents = discord.Intents.default()
|
||||
prikols = commands.Bot(intents=intents, command_prefix = '!')
|
||||
|
||||
# consts
|
||||
weekdays = ("Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье")
|
||||
current_week = '/html/body/main/div[2]/div/div/div[3]/div[4]/div[2]'
|
||||
options.headless = True
|
||||
intents.message_content = True
|
||||
intents.messages = True
|
||||
@@ -42,7 +43,7 @@ def get_element_from_driver(url : str, instruction : list) -> list:
|
||||
|
||||
return elem
|
||||
|
||||
def get_day_info(html : str) -> list:
|
||||
def get_day_info(html : str) -> str:
|
||||
'''Get's day of th week number
|
||||
posible numbers: 3-9 (included)'''
|
||||
|
||||
@@ -56,12 +57,16 @@ def get_day_info(html : str) -> list:
|
||||
|
||||
return soupa
|
||||
|
||||
# надо будет вынести 80 строчку в эту функцию ок?
|
||||
def get_current_week_number(html):
|
||||
# /html/body/main/div[2]/div/div/div[3]/div[4]/div[2]
|
||||
soup = BeautifulSoup(html, "lxml")
|
||||
current_week = soup.find("div")
|
||||
return current_week.text()
|
||||
def make_it_better(raw_day_info : str, current_week_num : int) -> dict:
|
||||
day_info = raw_day_info.split('\n')
|
||||
temp = []
|
||||
for i in day_info:
|
||||
if i.find('По второй неделе') != -1:
|
||||
temp.append(day_info.split(sep='По второй неделе')[current_week_num])
|
||||
else:
|
||||
temp.append(i)
|
||||
|
||||
return temp
|
||||
|
||||
@prikols.command()
|
||||
async def day(ctx, arg):
|
||||
@@ -74,14 +79,15 @@ async def day(ctx, arg):
|
||||
async def week(ctx):
|
||||
try:
|
||||
arr = []
|
||||
arr.append(current_week)
|
||||
for day in range(3,9):
|
||||
arr.append(f'/html/body/main/div[2]/div/div/div[3]/div[4]/div[{day}]')
|
||||
|
||||
arr.append('/html/body/main/div[2]/div/div/div[3]/div[4]/div[2]')
|
||||
html = get_element_from_driver(url=url, instruction=arr)
|
||||
|
||||
for i in range(len(html)):
|
||||
await ctx.send(weekdays[i] + f" {html[len(arr)-1]}" + "\n" + get_day_info(html[i]))
|
||||
await ctx.send(f"{html[len(arr)-1].strip()} | " + weekdays[i] + f'\n~ {i-2} пара ~\n' +
|
||||
"")
|
||||
except BaseException as err:
|
||||
await ctx.send(err)
|
||||
|
||||
@@ -89,5 +95,5 @@ async def week(ctx):
|
||||
async def on_ready():
|
||||
print('yolo')
|
||||
|
||||
# steal my token lol
|
||||
prikols.run('MTE5ODIwMTEwMTU2OTI0OTM4MA.G7h2hW.ei4EZVmva7SymBijBO9tcx8xhNBtQMMSu4AsE0')
|
||||
# now my token secured (maybe)
|
||||
prikols.run(f'{open('token', 'r').read()}')
|
||||
Reference in New Issue
Block a user