forked from Decentrala/chatbot
Added link to tasks
This commit is contained in:
parent
97d613df58
commit
dab4e41de0
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user