Added link to tasks

This commit is contained in:
t3xhno 2024-02-06 21:24:04 +01:00
parent 97d613df58
commit dab4e41de0
2 changed files with 4 additions and 4 deletions

View File

@ -24,6 +24,6 @@ def command(msg, rcpt):
cmd, query = msg.split(" ", 1)
return sf.query_external_website("https://en.wikipedia.org", "/wiki/" + query)
elif msg.startswith("!tasks"):
content = sf.getDmzTasks()
content = sf.getDmzTasks("https://todo.dmz.rs/")
return content

View File

@ -18,16 +18,16 @@ def query_external_website(base_url, query):
except Exception as e:
return e
def getDmzTasks():
def getDmzTasks(url):
try:
page = requests.get("https://todo.dmz.rs/")
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
tasks = soup.find_all(class_="task")
result = "\nActive tasks:\n"
for task in tasks:
taskIndex = task.select("div")[0].text
taskTitle = task.select("div")[1].text
result += taskIndex + " " + taskTitle + "\n"
result += taskIndex + " " + taskTitle + "|" + " Link: " + url + task.find("a")["href"][1:] + "\n"
return result
except Exception as e:
return e