summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2013-12-19 02:27:45 +0100
committerlassulus <lassulus@googlemail.com>2013-12-19 02:27:45 +0100
commit5e468c5d642311523cbc38cc84c9402072e48fd1 (patch)
tree7649e870de7af812a800c4d2a4b3fd31656daeee
parentec557236d0482a9f9285f803e1828d5f555e9ac8 (diff)
Reaktor/IRC: provide arguments to commands
-rwxr-xr-xReaktor/IRC/asybot.py4
-rw-r--r--Reaktor/TODO2
-rwxr-xr-xReaktor/commands/hello2
-rw-r--r--Reaktor/config.py2
4 files changed, 6 insertions, 4 deletions
diff --git a/Reaktor/IRC/asybot.py b/Reaktor/IRC/asybot.py
index d02a5747..08cba0e3 100755
--- a/Reaktor/IRC/asybot.py
+++ b/Reaktor/IRC/asybot.py
@@ -19,6 +19,7 @@ from sys import exit
from re import split, search, match
from textwrap import TextWrapper
import logging,logging.handlers
+import shlex
config_filename = './config.py'
@@ -145,6 +146,9 @@ class asybot(asychat):
#TODO: allow only commands below ./commands/
exe = join(dirname(realpath(dirname(__file__))), command['argv'][0])
myargv = [exe] + command['argv'][1:]
+ print(match.groupdict())
+ if 'args' in match.groupdict():
+ myargv += shlex.split(match.groupdict()['args'])
env = {}
env['_from'] = prefix.split('!', 1)[0]
diff --git a/Reaktor/TODO b/Reaktor/TODO
index c1b56de0..23887cf3 100644
--- a/Reaktor/TODO
+++ b/Reaktor/TODO
@@ -2,6 +2,4 @@ commands/caps: merge load_config with IRC/getconf.py
getconf: reload inotify
-provide arguments to commands
-
check own username
diff --git a/Reaktor/commands/hello b/Reaktor/commands/hello
index df3b6bb9..05ed79b5 100755
--- a/Reaktor/commands/hello
+++ b/Reaktor/commands/hello
@@ -1,2 +1,2 @@
#! /bin/sh
-echo "Hello${argument+, $argument}!"
+echo "Hello${*+, $*}!"
diff --git a/Reaktor/config.py b/Reaktor/config.py
index 0ae76811..2dd6ac2f 100644
--- a/Reaktor/config.py
+++ b/Reaktor/config.py
@@ -17,7 +17,7 @@ irc_channels = [
def default_command(cmd):
return {
'capname': cmd,
- 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*$',
+ 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P<args>.*))?$',
'argv': [ 'commands/' + cmd ] }
commands = [