Added tasks integration
This commit is contained in:
parent
1e56a84a4c
commit
97d613df58
@ -23,4 +23,7 @@ def command(msg, rcpt):
|
||||
elif msg.startswith("!wiki"):
|
||||
cmd, query = msg.split(" ", 1)
|
||||
return sf.query_external_website("https://en.wikipedia.org", "/wiki/" + query)
|
||||
elif msg.startswith("!tasks"):
|
||||
content = sf.getDmzTasks()
|
||||
return content
|
||||
|
||||
|
@ -17,3 +17,17 @@ def query_external_website(base_url, query):
|
||||
return "\nTITLE:\n" + title + "\n\nCONTENT:\n" + content.text + "\n\nFULL LINK:\n" + base_url + quote(query)
|
||||
except Exception as e:
|
||||
return e
|
||||
|
||||
def getDmzTasks():
|
||||
try:
|
||||
page = requests.get("https://todo.dmz.rs/")
|
||||
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"
|
||||
return result
|
||||
except Exception as e:
|
||||
return e
|
||||
|
Loading…
Reference in New Issue
Block a user