From 041ac0e9767966a7cedb6f017f2647f6b1bc3eaa Mon Sep 17 00:00:00 2001 From: plocki Date: Thu, 30 Jan 2020 21:56:03 +0100 Subject: [PATCH] =?UTF-8?q?weather.py=20f=C3=BCr=20ansiweather?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/weather.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 modules/weather.py diff --git a/modules/weather.py b/modules/weather.py new file mode 100644 index 0000000..89a1cef --- /dev/null +++ b/modules/weather.py @@ -0,0 +1,16 @@ +import subprocess +import os + +class MatrixModule: + async def matrix_message(self, bot, room, event): + args = event.body.split() + args.pop(0) + encoding="utf-8" + + # get weather from ansiweather + result = subprocess.check_output(["ansiweather","-a false","-l", ' '.join(args)]) + + await bot.send_text(room, result.decode(encoding)) + + def help(self): + return('How\'s the weather?')