added some broken functions

This commit is contained in:
2024-09-22 13:02:14 +09:00
parent d66849b092
commit 9f49a41da6

30
main.py
View File

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