Skip to content
Snippets Groups Projects
Commit 91c5cfd7 authored by overflow's avatar overflow
Browse files

reformatted code and added find_room the feature handler

parent 80ee4af9
No related branches found
No related tags found
No related merge requests found
...@@ -7,20 +7,14 @@ import os ...@@ -7,20 +7,14 @@ import os
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import requests import requests
def find_room():
def find_room(sender, message):
html = requests.get("https://foss-ag.de/").text html = requests.get("https://foss-ag.de/").text
soup = BeautifulSoup(html, 'html.parser') soup = BeautifulSoup(html, 'html.parser')
date = ( date = soup.find(id="ag-termine").find_next_sibling("div").find("ul").find("li").get_text().strip()
soup
.find(id="ag-termine")
.find_next_sibling("div")
.find("ul")
.find("li")
.get_text()
.strip()
)
return date return date
def main(): def main():
# connect to server and join room # connect to server and join room
client = MatrixClient("https://matrix.org") client = MatrixClient("https://matrix.org")
...@@ -31,7 +25,7 @@ def main(): ...@@ -31,7 +25,7 @@ def main():
fh = FeatureHandler(room, client) fh = FeatureHandler(room, client)
# add features to FeatureHandler that are called when the specified command is posted in the Matrix room # add features to FeatureHandler that are called when the specified command is posted in the Matrix room
fh.add_feature("!echo", FeatureExamples.echo) fh.add_feature("!echo", FeatureExamples.echo)
fh.add_feature("!CUPS", FeatureExamples.caps) fh.add_feature("!room", find_room)
# run script until it's stopped manually # run script until it's stopped manually
while True: while True:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment