hemppa/modules/weather.py

18 lines
482 B
Python
Raw Normal View History

2020-01-30 22:56:03 +02:00
import subprocess
2020-02-02 23:08:15 +02:00
from modules.common.module import BotModule
2020-01-30 22:56:03 +02:00
2020-02-02 23:08:15 +02:00
class MatrixModule(BotModule):
2020-01-30 22:56:03 +02:00
async def matrix_message(self, bot, room, event):
args = event.body.split()
args.pop(0)
2020-02-02 23:08:15 +02:00
encoding = "utf-8"
2020-01-30 22:56:03 +02:00
# get weather from ansiweather
2020-02-02 23:08:15 +02:00
result = subprocess.check_output(["ansiweather", "-a false", "-l", ' '.join(args)])
2020-01-30 22:56:03 +02:00
await bot.send_text(room, result.decode(encoding))
def help(self):
2020-02-02 23:08:15 +02:00
return ('How\'s the weather?')