diff options
author | Livio Recchia <recchialivio@libero.it> | 2020-04-05 22:36:42 +0200 |
---|---|---|
committer | Livio Recchia <recchialivio@libero.it> | 2020-04-05 22:36:42 +0200 |
commit | 91bcf60a0edfa81c5b507c4c93e6b839be24f2db (patch) | |
tree | 5016d7d95181ef3b46c9999e3026149dda261389 /plugins | |
parent | 19a25076dcddb4c1219909cf7572b85e9b4d4a2a (diff) | |
download | manachat-91bcf60a0edfa81c5b507c4c93e6b839be24f2db.tar.gz manachat-91bcf60a0edfa81c5b507c4c93e6b839be24f2db.tar.bz2 manachat-91bcf60a0edfa81c5b507c4c93e6b839be24f2db.tar.xz manachat-91bcf60a0edfa81c5b507c4c93e6b839be24f2db.zip |
Changed calculations feature
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/manaboy.py | 39 | ||||
-rw-r--r--[-rwxr-xr-x] | plugins/manaboy.pyc | bin | 39617 -> 39568 bytes |
2 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 =========== diff --git a/plugins/manaboy.pyc b/plugins/manaboy.pyc Binary files differindex b4f5fd8..776e053 100755..100644 --- a/plugins/manaboy.pyc +++ b/plugins/manaboy.pyc |