aboutsummaryrefslogtreecommitdiffstats
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
commitf0768b7253bc37434a8594d6f8a5acc033356085 (patch)
treee3cb266e8e2d7c03295a171d420f4f1dd342f89c
parent5083bed0ca1fa61436dab03d5df5036ef92355af (diff)
Reaktor/IRC: provide arguments to commands
-rwxr-xr-xIRC/asybot.py4
-rw-r--r--TODO2
-rwxr-xr-xcommands/hello2
-rw-r--r--config.py2
4 files changed, 6 insertions, 4 deletions
diff --git a/IRC/asybot.py b/IRC/asybot.py
index d02a574..08cba0e 100755
--- a/IRC/asybot.py
+++ b/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/TODO b/TODO
index c1b56de..23887cf 100644
--- a/TODO
+++ b/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/commands/hello b/commands/hello
index df3b6bb..05ed79b 100755
--- a/commands/hello
+++ b/commands/hello
@@ -1,2 +1,2 @@
#! /bin/sh
-echo "Hello${argument+, $argument}!"
+echo "Hello${*+, $*}!"
diff --git a/config.py b/config.py
index 0ae7681..2dd6ac2 100644
--- a/config.py
+++ b/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 = [