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) cmd, query = msg.split(" ", 1)
return sf.query_external_website("https://en.wikipedia.org", "/wiki/" + query) return sf.query_external_website("https://en.wikipedia.org", "/wiki/" + query)
elif msg.startswith("!tasks"): elif msg.startswith("!tasks"):
content = sf.getDmzTasks() content = sf.getDmzTasks("https://todo.dmz.rs/")
return content return content

View File

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