-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmultilinecommand.lic
More file actions
68 lines (61 loc) · 1.52 KB
/
multilinecommand.lic
File metadata and controls
68 lines (61 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
toggle_unique
upstreamHookName = 'multiline-command'
def sendDownstream(val)
end
class MultilineCommand
def MultilineCommand.getLines(input)
strings = input.split("#{$lich_char}#{$lich_char}")
strings.each { |s| s.chomp! }
end
end
if scrToKill = (Script.running).select { |val| val.name == "multilinecommand" }
scrToKill.each { |scr| if scr != Script.current then scr.kill() end }
end
action = proc { |client_string|
if client_string =~ /^(?:<c>)?#{$lich_char}.*/
client_string #we don't want to eat script commands
elsif client_string =~ /^(?:<c>)?([^#{$lich_char}]+#{$lich_char}#{$lich_char}.+)/
capture = $1
retVal = nil
if scr = (Script.running).find { |val| val.name == "multilinecommand" }
strings = MultilineCommand.getLines($1)
if strings.length > 1
for i in 0..(strings.length-1)
act = strings[i]
scr.unique_buffer.shove("#{act}") #if this script is still running send the command
end
nil
else
strings[0]
end
else
UpstreamHook.remove(upstreamHookName) #if the script isnt running remove the hook
client_string
end
else
client_string #No split-char
end
}
UpstreamHook.remove(upstreamHookName)
UpstreamHook.add(upstreamHookName, action)
before_dying {
UpstreamHook.remove(upstreamHookName);
Object.send(:remove_const, :MultilineCommand)
}
while line = unique_get
begin
put line
rescue Exception
echo $!
echo $!.backtrace.first
sleep 1
rescue ThreadError
echo $!
echo $!.backtrace.first
sleep 1
rescue
echo $!
echo $!.backtrace.first
sleep 1
end
end