2 # Someone's Mattermost scripts.
3 # Copyright (c) 2016-2020 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
4 # published under MIT-License
9 from inspect import cleandoc
17 rex_wtops = re.compile(r"^={1,3}[^=].*$", re.IGNORECASE|re.MULTILINE)
20 def process_wiki(mws, mm):
21 # notify of upcomming events. (up to: now +- 30 min)
22 page = mws.Pages["TOPs_der_kommenden_Fachschaftssitzung"]
24 found = [re.sub(r"\s*=+\s*$", "", "+ ".join([re.sub(r"^(=+)\s*", r"\g<1>+ ", x).split("+ ", 1)[0].replace("=", " "), re.sub(r"^(=+)\s*", r"\g<1>+ ", x).split("+ ", 1)[1]])) for x in re.findall(rex_wtops, page.text())]
26 msg = "``BOT-AUTODELETE-SLOW``\n### :warning: ``Upcoming FSS-TOPs`` :warning:\n@channel Zwecks Hut-Top-Minimierung, trage bitte deine TOPs asap ein. :)!\n"
27 msg += ":arrow_right: https://intern.fsinf.at/wiki/TOPs_der_kommenden_Fachschaftssitzung\n\n----\n"
28 msg += cleandoc("\n".join(found))
29 print("Posting to channel:" +str(mm.create_post(config.mm_chanid, msg)))
32 if __name__ == "__main__":
33 mws = mwclient.Site(config.mw_name, path="/")
34 mws.login(config.mw_user, config.mw_user_pw)
35 mm = mattermost.MMApi(config.mm_api_url)
36 mm.login(config.mm_user, config.mm_user_pw)