File: exec_command.tcl

package info (click to toggle)
tkabber 0.9.9-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,028 kB
  • ctags: 1,798
  • sloc: tcl: 36,852; xml: 3,704; sh: 1,386; makefile: 67
file content (27 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (2)
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
# $Id: exec_command.tcl,v 1.3 2004/02/08 19:02:27 aleksey Exp $

proc handle_exec_command {chatid user body type} {
    if {[string equal -length 6 $body "/exec "]} {
	set iw [chat::input_win $chatid]
	set command [crange $body 6 end]
	set res [catch {set output [eval exec $command]} errMsg]
	if {$res} {
	    set msg $errMsg
	} else {
	    set msg $output
	}
	after idle [list $iw insert end "\$ $command\n" {} $msg]
	return stop
    }
}
hook::add chat_send_message_hook [namespace current]::handle_exec_command 15

proc exec_command_comps {chatid compsvar wordstart line} {
    upvar 0 $compsvar comps
    
    if {!$wordstart} {
	lappend comps {/exec }
    }
}

hook::add generate_completions_hook [namespace current]::exec_command_comps