From: Christian Weiske Date: Sun, 18 Mar 2018 22:09:14 +0000 (+0100) Subject: Support errbot 5 and python 3 X-Git-Url: https://git.cweiske.de/errbot-exec.git/commitdiff_plain/refs/heads/master Support errbot 5 and python 3 --- 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"