From 2d1b9414edc8aa57adbe9ac547292921936d874a Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 25 Mar 2014 09:46:43 +0100 Subject: add eloop to IRc/reaktor --- Reaktor/config.py | 1 + 1 file changed, 1 insertion(+) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 2dd6ac2f..928c49d7 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -10,6 +10,7 @@ irc_kill_timeout = 360 irc_nickname = name irc_server = 'irc.freenode.org' irc_port = 6667 +#irc_restart_timeout = 5 irc_channels = [ '#krebs' ] -- cgit v1.2.3 From c5accb6ea72ac9612dddf37541661fa544d5b872 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 25 Mar 2014 15:35:52 +0100 Subject: add authentication to Reaktor using /query identify configuration contains commands and public_commands --- Reaktor/config.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 928c49d7..88ae837c 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -10,21 +10,21 @@ irc_kill_timeout = 360 irc_nickname = name irc_server = 'irc.freenode.org' irc_port = 6667 -#irc_restart_timeout = 5 +irc_restart_timeout = 5 irc_channels = [ '#krebs' ] - +admin_file='admin.lst' +auth_file='auth.lst' def default_command(cmd): return { 'capname': cmd, 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', 'argv': [ 'commands/' + cmd ] } -commands = [ +public_commands = [ default_command('caps'), default_command('hello'), - default_command('reload'), default_command('badcommand'), default_command('rev'), default_command('uptime'), @@ -34,5 +34,12 @@ commands = [ 'argv': [ 'commands/respond','You are made of stupid!'] }, # "highlight" { 'pattern': '.*\\b' + name + '\\b.*', - 'argv': [ 'commands/say', 'I\'m famous' ] } + 'argv': [ 'commands/say', 'I\'m famous' ] }, + # identify via direct connect + { 'capname': 'identify', + 'pattern': 'identify' + '\\s*(?:\\s+(?P.*))?$', + 'argv' : [ 'commands/identify' ]} +] +commands = [ + default_command('reload') ] -- cgit v1.2.3 From 01d8f1f70a889519fd181f889e070450b8e62c97 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 20 Apr 2014 12:13:33 +0200 Subject: reaktor.py: set cwd --- Reaktor/config.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 88ae837c..88701379 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -1,9 +1,12 @@ +from os import environ debug = True # CAVEAT name should not contains regex magic name = 'crabmanner' +workdir = environ['HOME'] + '/state' + irc_alarm_timeout = 300 irc_hammer_interval = 10 irc_kill_timeout = 360 -- cgit v1.2.3 From 231c6e68078ea86f48d91ed065794fce52c25ac6 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 20 Apr 2014 12:30:17 +0200 Subject: reaktor.py: add on_join hook: tell NICK MSG... --- Reaktor/config.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 88701379..db4c8a3e 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -32,6 +32,12 @@ public_commands = [ default_command('rev'), default_command('uptime'), default_command('nocommand'), + { + 'capname': 'tell', + 'pattern': '^' + name + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P.*))?$', + 'argv': [ 'commands/tell-on_privmsg' ], + 'env': { 'state_file': workdir + '/tell.txt' } + }, # command not found { 'pattern': '^(?:' + name + '|\\*):.*', 'argv': [ 'commands/respond','You are made of stupid!'] }, @@ -46,3 +52,11 @@ public_commands = [ commands = [ default_command('reload') ] + +on_join = [ + { + 'capname': 'tell', + 'argv': [ 'commands/tell-on_join' ], + 'env': { 'state_file': workdir + '/tell.txt' } + } +] -- cgit v1.2.3 From 2ac7e46d6f242e299d2ad2a3f631dd45d3d95cba Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 25 Apr 2014 12:22:40 +0200 Subject: Reaktor:fix ^ --- Reaktor/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index db4c8a3e..0a01c5cb 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -46,7 +46,7 @@ public_commands = [ 'argv': [ 'commands/say', 'I\'m famous' ] }, # identify via direct connect { 'capname': 'identify', - 'pattern': 'identify' + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^identify' + '\\s*(?:\\s+(?P.*))?$', 'argv' : [ 'commands/identify' ]} ] commands = [ -- cgit v1.2.3 From 2ff3166d78710db3f6346cdb743f8ff7d3e7e1a3 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Apr 2014 12:58:24 +0200 Subject: reaktor config: use expanduser instead of environ --- Reaktor/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 0a01c5cb..4ca6d377 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -1,11 +1,11 @@ -from os import environ +from os.path import expanduser debug = True # CAVEAT name should not contains regex magic name = 'crabmanner' -workdir = environ['HOME'] + '/state' +workdir = expanduser('~') + '/state' irc_alarm_timeout = 300 irc_hammer_interval = 10 -- cgit v1.2.3 From 4fbc3dd22e5ee5c04fd346a9424f796e671a6f05 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Apr 2014 13:08:46 +0200 Subject: reaktor: name must not be able to kill patterns --- Reaktor/config.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 4ca6d377..48406bf9 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -1,8 +1,8 @@ from os.path import expanduser +import re debug = True -# CAVEAT name should not contains regex magic name = 'crabmanner' workdir = expanduser('~') + '/state' @@ -19,10 +19,14 @@ irc_channels = [ ] admin_file='admin.lst' auth_file='auth.lst' + +# name_re is used, so name cannot kill our patterns below +name_re = re.escape(name) + def default_command(cmd): return { 'capname': cmd, - 'pattern': '^(?:' + name + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^(?:' + name_re + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', 'argv': [ 'commands/' + cmd ] } public_commands = [ @@ -34,15 +38,15 @@ public_commands = [ default_command('nocommand'), { 'capname': 'tell', - 'pattern': '^' + name + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^' + name_re + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P.*))?$', 'argv': [ 'commands/tell-on_privmsg' ], 'env': { 'state_file': workdir + '/tell.txt' } }, # command not found - { 'pattern': '^(?:' + name + '|\\*):.*', + { 'pattern': '^(?:' + name_re + '|\\*):.*', 'argv': [ 'commands/respond','You are made of stupid!'] }, # "highlight" - { 'pattern': '.*\\b' + name + '\\b.*', + { 'pattern': '.*\\b' + name_re + '\\b.*', 'argv': [ 'commands/say', 'I\'m famous' ] }, # identify via direct connect { 'capname': 'identify', -- cgit v1.2.3 From e1571b5a5cda983234cd6d5c4998ab883cc46115 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Apr 2014 13:19:50 +0200 Subject: reaktor config: unify ^(|*): --- Reaktor/config.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 48406bf9..90540340 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -20,13 +20,14 @@ irc_channels = [ admin_file='admin.lst' auth_file='auth.lst' -# name_re is used, so name cannot kill our patterns below -name_re = re.escape(name) +# me is used, so name cannot kill our patterns below +me = '\\b' + re.escape(name) + '\\b' +me_or_us = '(?:' + me + '|\\*)' def default_command(cmd): return { 'capname': cmd, - 'pattern': '^(?:' + name_re + '|\\*):\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^' + me_or_us + ':\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', 'argv': [ 'commands/' + cmd ] } public_commands = [ @@ -38,19 +39,19 @@ public_commands = [ default_command('nocommand'), { 'capname': 'tell', - 'pattern': '^' + name_re + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^' + me_or_us + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P.*))?$', 'argv': [ 'commands/tell-on_privmsg' ], 'env': { 'state_file': workdir + '/tell.txt' } }, # command not found - { 'pattern': '^(?:' + name_re + '|\\*):.*', + { 'pattern': '^' + me_or_us + ':.*', 'argv': [ 'commands/respond','You are made of stupid!'] }, # "highlight" - { 'pattern': '.*\\b' + name_re + '\\b.*', + { 'pattern': '.*' + me + '.*', 'argv': [ 'commands/say', 'I\'m famous' ] }, # identify via direct connect { 'capname': 'identify', - 'pattern': '^identify' + '\\s*(?:\\s+(?P.*))?$', + 'pattern': '^identify' + '\\s*(?:\\s+(?P.*))?$', 'argv' : [ 'commands/identify' ]} ] commands = [ -- cgit v1.2.3 From 7bf0b790b95d97d33e57a4e52cf7681bc6366d98 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Apr 2014 13:34:04 +0200 Subject: reaktor: move config_filename to config --- Reaktor/config.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 90540340..7f3f9c40 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -1,4 +1,4 @@ -from os.path import expanduser +from os.path import abspath, expanduser import re debug = True @@ -20,18 +20,24 @@ irc_channels = [ admin_file='admin.lst' auth_file='auth.lst' +config_filename = abspath(__file__) + # me is used, so name cannot kill our patterns below me = '\\b' + re.escape(name) + '\\b' me_or_us = '(?:' + me + '|\\*)' -def default_command(cmd): +def default_command(cmd, env={}): return { 'capname': cmd, 'pattern': '^' + me_or_us + ':\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', - 'argv': [ 'commands/' + cmd ] } + 'argv': [ 'commands/' + cmd ], + 'env': env + } public_commands = [ - default_command('caps'), + default_command('caps', env={ + 'config_filename': config_filename + }), default_command('hello'), default_command('badcommand'), default_command('rev'), -- cgit v1.2.3 From 14751fbcb177f70cf8989f4d27c566b2576ebb70 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Apr 2014 13:42:45 +0200 Subject: reaktor config: tell is a default_command --- Reaktor/config.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 7f3f9c40..5ea991b0 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -26,10 +26,11 @@ config_filename = abspath(__file__) me = '\\b' + re.escape(name) + '\\b' me_or_us = '(?:' + me + '|\\*)' -def default_command(cmd, env={}): +def default_command(cap, cmd=None, env={}): + if cmd == None: cmd=cap return { - 'capname': cmd, - 'pattern': '^' + me_or_us + ':\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', + 'capname': cap, + 'pattern': '^' + me_or_us + ':\\s*' + cap + '\\s*(?:\\s+(?P.*))?$', 'argv': [ 'commands/' + cmd ], 'env': env } @@ -43,12 +44,9 @@ public_commands = [ default_command('rev'), default_command('uptime'), default_command('nocommand'), - { - 'capname': 'tell', - 'pattern': '^' + me_or_us + ':\\s*' + 'tell' + '\\s*(?:\\s+(?P.*))?$', - 'argv': [ 'commands/tell-on_privmsg' ], - 'env': { 'state_file': workdir + '/tell.txt' } - }, + default_command('tell', cmd='tell-on_privmsg', env={ + 'state_file': workdir + '/tell.txt' + }), # command not found { 'pattern': '^' + me_or_us + ':.*', 'argv': [ 'commands/respond','You are made of stupid!'] }, -- cgit v1.2.3 From 9e5e76fd2532a47b0cc47f4d01266b7c35299470 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Apr 2014 13:43:08 +0200 Subject: reaktor config: identify needs config_filename --- Reaktor/config.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 5ea991b0..eba1f093 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -56,7 +56,11 @@ public_commands = [ # identify via direct connect { 'capname': 'identify', 'pattern': '^identify' + '\\s*(?:\\s+(?P.*))?$', - 'argv' : [ 'commands/identify' ]} + 'argv' : [ 'commands/identify' ], + 'env': { + 'config_filename': config_filename + } + } ] commands = [ default_command('reload') -- cgit v1.2.3 From ebf658d66ce61a21c3363a8313d847efaf13d21c Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Apr 2014 13:48:34 +0200 Subject: reaktor config: introduce simple_command --- Reaktor/config.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index eba1f093..90f33d38 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -35,6 +35,15 @@ def default_command(cap, cmd=None, env={}): 'env': env } +def simple_command(cap, cmd=None, env={}): + if cmd == None: cmd=cap + return { + 'capname': cap, + 'pattern': '^' + cap + '\\s*(?:\\s+(?P.*))?$', + 'argv' : [ 'commands/' + cmd ], + 'env': env + } + public_commands = [ default_command('caps', env={ 'config_filename': config_filename @@ -54,13 +63,9 @@ public_commands = [ { 'pattern': '.*' + me + '.*', 'argv': [ 'commands/say', 'I\'m famous' ] }, # identify via direct connect - { 'capname': 'identify', - 'pattern': '^identify' + '\\s*(?:\\s+(?P.*))?$', - 'argv' : [ 'commands/identify' ], - 'env': { - 'config_filename': config_filename - } - } + simple_command('identify', env={ + 'config_filename': config_filename + }) ] commands = [ default_command('reload') -- cgit v1.2.3 From 88ccd47a9b569db8c239a0abda1185dd647fb906 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 25 Apr 2014 14:18:25 +0200 Subject: fix {} in default_command function --- Reaktor/config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 7f3f9c40..5858532e 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -17,8 +17,8 @@ irc_restart_timeout = 5 irc_channels = [ '#krebs' ] -admin_file='admin.lst' -auth_file='auth.lst' +admin_file=workdir+'/admin.lst' +auth_file=workdir+'/auth.lst' config_filename = abspath(__file__) @@ -26,7 +26,8 @@ config_filename = abspath(__file__) me = '\\b' + re.escape(name) + '\\b' me_or_us = '(?:' + me + '|\\*)' -def default_command(cmd, env={}): +def default_command(cmd, env=None): + if not env: env = {} return { 'capname': cmd, 'pattern': '^' + me_or_us + ':\\s*' + cmd + '\\s*(?:\\s+(?P.*))?$', -- cgit v1.2.3 From 95fbba75246cf1b5115bc5493d3119f9ea91221e Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 27 Apr 2014 18:18:08 +0200 Subject: update things --- Reaktor/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index 424019a7..ea00693f 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -1,7 +1,7 @@ from os.path import abspath, expanduser import re -debug = True +debug = False name = 'crabmanner' -- cgit v1.2.3 From 92fe3350fe6e3da26fa1ad0522aabaa0f146d575 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 5 May 2014 09:53:32 +0200 Subject: Merge all the shits --- Reaktor/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Reaktor/config.py') diff --git a/Reaktor/config.py b/Reaktor/config.py index ea00693f..b1158271 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -5,7 +5,8 @@ debug = False name = 'crabmanner' -workdir = expanduser('~') + '/state' +#workdir = expanduser('~') + '/state' +workdir = '/home/reaktor/state' irc_alarm_timeout = 300 irc_hammer_interval = 10 -- cgit v1.2.3