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
17 REXwreminder_line = re.compile(r"^\s*(\{\{mm-reminder\|[^\|\}]+\|.*\}\}.*)$", re.IGNORECASE|re.MULTILINE)
18 REXwreminder_data = re.compile(r"^^\s*\{\{mm-reminder\|([^\|\}]+)\|?(.*\}\}.*)$", re.IGNORECASE)
21 def processData(mws, mm, datasource, matchdata):
22 match = re.match(REXwreminder_data, matchdata)
24 timediff = datetime.datetime.now() - datetime.datetime.strptime(match.group(1), "%Y-%m-%d %H:%M")
25 if abs(timediff.total_seconds()) > 1800.0:
26 print("outside of 1800 sec.")
29 msg = "``BOT-AUTODELETE-SLOW`` Termin-Reminder source: "+datasource+"\n### ``"+(match.group(2).replace("}}", "``", 1))
30 print("Posting to channel:" +str(mm.create_post(config.mm_chanid, msg)))
33 def processWiki(mws, mm):
34 # notify of upcomming events. (up to: now +- 30 min)
35 page = mws.Pages["TOPs_der_kommenden_Fachschaftssitzung"]
37 for t in re.findall(REXwreminder_line, page.text()):
39 processData(mws, mm, "https://"+config.mw_name+"/wiki/TOPs_der_kommenden_Fachschaftssitzung", t)
44 if __name__ == "__main__":
45 mws = mwclient.Site(config.mw_name, path="/")
46 mws.login(config.mw_user, config.mw_user_pw)
47 mm = mattermost.MMApi(config.mm_api_url)
48 mm.login(config.mm_user, config.mm_user_pw)