From 9bc1260d38decef7746e6d5a0a76d51f405f549e Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sun, 18 Mar 2018 23:09:14 +0100 Subject: [PATCH] Support errbot 5 and python 3 --- exec.plug | 5 ++--- exec.py | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/exec.plug b/exec.plug index bde04e8..849ccd9 100644 --- a/exec.plug +++ b/exec.plug @@ -9,6 +9,5 @@ description = Execute a command when the bot is talked to version = 2+ [Errbot] -min = 4.0.0 -max = 4.99.99 - +min = 5.0.0 +max = 5.99.99 diff --git a/exec.py b/exec.py index 207a4f9..d91fc2b 100644 --- a/exec.py +++ b/exec.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import os, re, subprocess -from errbot import BotPlugin, botcmd, re_botcmd -from errbot.utils import ValidationException +from errbot import BotPlugin, botcmd, re_botcmd, ValidationException class Exec(BotPlugin): """ @@ -60,15 +59,15 @@ class Exec(BotPlugin): """ try: output = subprocess.check_output( - [self.config['command'], unicode(msg.body), unicode(msg.frm)], + [self.config['command'], msg.body, str(msg.frm)], stderr=subprocess.STDOUT ) if len(output) > 0: - return unicode(output, 'utf-8') + return str(output, 'utf-8') else: return "OK\n" except subprocess.CalledProcessError as err: if len(err.output): - return unicode(err.output, 'utf-8') + return str(err.output, 'utf-8') else: return "Error" -- 2.30.2