summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xautofast.sh8
-rwxr-xr-xplugins/manaboy.py39
-rw-r--r--[-rwxr-xr-x]plugins/manaboy.pycbin39617 -> 39568 bytes
3 files changed, 40 insertions, 7 deletions
diff --git a/autofast.sh b/autofast.sh
new file mode 100755
index 0000000..24c940c
--- /dev/null
+++ b/autofast.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+while :
+do
+ echo "Loading manachat (abort with CTRL+C). REDUCED RELOG TIME: DEVELOPMENT PURPOSE ONLY"
+ # Increase nice number in order to be the last served by kernel
+ nice -n 19 ./simple.py
+ sleep 3
+done
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
index b4f5fd8..776e053 100755..100644
--- a/plugins/manaboy.pyc
+++ b/plugins/manaboy.pyc
Binary files differ