k 5 Reaktor.plugins: fix sed-plugin

This commit is contained in:
makefu 2015-12-30 11:52:22 +01:00
parent c962e8549e
commit f0ce9a72a6

View file

@ -14,6 +14,7 @@ rec {
buildSimpleReaktorPlugin = name: { script buildSimpleReaktorPlugin = name: { script
, path ? [] , path ? []
, env ? {} , env ? {}
, append_rule ? false # append the rule instead of insert
, pattern ? "" , pattern ? ""
, ... } @ attrs: , ... } @ attrs:
let let
@ -26,7 +27,7 @@ rec {
}); });
src_file = "${src_dir}/bin/${name}"; src_file = "${src_dir}/bin/${name}";
config = '' config = ''
public_commands.insert(0,{ public_commands.${if append_rule then "append(" else "insert(0," }{
'capname' : "${name}", 'capname' : "${name}",
'pattern' : ${if pattern == "" then 'pattern' : ${if pattern == "" then
''indirect_pattern.format("${name}")'' else ''indirect_pattern.format("${name}")'' else
@ -58,9 +59,10 @@ rec {
}; };
sed-plugin = buildSimpleReaktorPlugin "sed-plugin" { sed-plugin = buildSimpleReaktorPlugin "sed-plugin" {
path = [ pkgs.gnused ]; path = [ pkgs.gnused pkgs.python3 ];
# only support s///gi the plugin needs to see every msg # only support s///gi the plugin needs to see every msg
# TODO: this will eat up the last regex, fix Reaktor to support fallthru # TODO: this will eat up the last regex, fix Reaktor to support fallthru
append_rule = true;
pattern = "^(?P<args>.*)$$"; pattern = "^(?P<args>.*)$$";
script = ./scripts/sed-plugin.py; script = ./scripts/sed-plugin.py;
}; };
@ -105,7 +107,7 @@ rec {
config = '' config = ''
def titlebot_cmd(cmd): def titlebot_cmd(cmd):
from os import environ from os import environ
return { 'capname': cmd, return { 'capname': None,
'env': { 'TITLEDB': 'env': { 'TITLEDB':
environ['state_dir']+'/suggestions.json' }, environ['state_dir']+'/suggestions.json' },
'pattern': '^\\.' + cmd + '\\s*(?:\\s+(?P<args>.*))?$$', 'pattern': '^\\.' + cmd + '\\s*(?:\\s+(?P<args>.*))?$$',