diff options
Diffstat (limited to 'plugins/manaboy.py')
-rwxr-xr-x | plugins/manaboy.py | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/plugins/manaboy.py b/plugins/manaboy.py index c5480b6..0578e21 100755 --- a/plugins/manaboy.py +++ b/plugins/manaboy.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import subprocess import time import net.mapserv as mapserv import net.charserv as charserv @@ -42,25 +43,49 @@ friends = preloadArray("bot/friends.txt") # ====================== XECUTE ============= def XECUTE(nick, is_whisper, command, args=""): + if nick in ignored_players: + return try: - import subprocess if args=="": s = subprocess.check_output([command]) else: s = subprocess.check_output([command, args]) except: - s=("Damn! " +match.group(1)+" + has failed!").strip() + s=("Damn! Command has failed! " + command).strip() if is_whisper: - whisper(nick,(s)) + whisper(nick,(s.strip('\r\n\t'))) else: - mapserv.cmsg_chat_message(s) + mapserv.cmsg_chat_message(s.strip('\r\n\t')) # ====================== XCAL ============= def XCAL(nick, message, is_whisper, match): - if nick in ignored_players: - return - XECUTE(nick, is_whisper, "/home/livio/Nextcloud/mcu/prj/test_cparse/a.out",match.group(1)) + + XECUTE(nick, is_whisper, "calc",match.group(1)) + # ~ XECUTE(nick, is_whisper, "echo \'" + match.group(1) + "\' | bc") + + # ~ try: + # ~ p = subprocess.Popen(['/home/livio/livio/a.out'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) + # ~ p.stdin.write("\'" + match.group(1) + "\'") + # ~ p.stdin.flush() + # ~ while p.poll() == None: + + # ~ s = p.stdout.readline().strip() + # ~ except OSError as e: + # ~ s = "Execution dammit failed!" + # ~ print e + + # ~ if is_whisper: + # ~ whisper(nick,s) + # ~ else: + # ~ mapserv.cmsg_chat_message(s) + # ~ try: + # ~ s = subprocess.getoutput("echo \'" + match.group(1) + "\' | bc") # Dammit. This one is not good. Shell command injection is possible. + + # ~ except OSError as e: + # ~ s = "Execution dammit failed: "+ e + + # === eXecute on Unix =========== |