Thread: alias
View Single Post
Old 13-07-2005, 16:52   #5 (permalink)
AdrianK
Member
 
Join Date: Jun 2004
Location: Canada
Age: 18
Posts: 145
Rep Power: 0
AdrianK is on a distinguished road
Default

Am corectat. Deci o varianta fina ar fi:


Code:
a:command -add alias	pub:alias	1600 1500 |N

proc pub:alias {hand chan args x mix} {
	
	set comm [lindex $args 0]
	set aka  [lindex $args 1]
	
	if {![string length $comm]}		 { a:usage $x alias; return "FAILED: not all paramatres specified"}
	if { [regexp {^(-remove|-r)$} $comm] && $aka!=""} {if {[string equal -nocase all $aka]} {alias -clean $chan; a:tell $x 1703 ; return "removed all"} {if {![alias -exists $chan $aka]} {a:tell $x 1700 $aka; return "no such alias ($aka)"} {a:tell $x 1701 $aka; alias -remove $chan $aka; return "removed $aka"}}}
	if { [regexp {^(-list|-l)$} $comm]} {set list [alias -list $chan]; if {![llength $list]} {a:tell $x 1705 $chan; return "failed empty"} {a:tell $x 17 $list; return $list}}
	if {![a:command -exists $comm]}	   {a:tell $x 18 $comm; return "FAILED: invalid command specified ($comm)"}
	if {![string length $aka]}		  { a:usage $x alias; return "FAILED: not all paramatres specified"}
	if { [a:command -exists $aka] || [alias -exists $chan $aka]} {a:tell $x 1706 $aka; return "failed already exists a command name/alias $aka"}
	if { [alias -number $chan] >= 15}   {a:tell $x 1704; return "failed already have 15 aliases"}
	
	alias -add $chan $comm $aka
	
	a:tell $x 1702 "$aka $comm"
	
	return "$comm" 
}

in fisierul de limbaj a&a_04_a_dict_en.tcl sa adaugi

set say(lang.1.1500)  "usage: «alias \[-remove|-list\] <command> <alias> \[all\] «"

set say(lang.1.1600)  "help: Define any ALIAS to any BOT command (you can specify up to 15 aliases per chan)"

set say(lang.1.1700)   "error: i have no info about %B«%B alias ..."
set say(lang.1.1701)   "Removed %B«%B alias ..."
set say(lang.1.1702)   "Added %r«%% as alias for command %b«%%."
set say(lang.1.1703)   "Removed all aliases."
set say(lang.1.1704)   "error: You can only set 15 aliases."
set say(lang.1.1705)   "error: No alias defined for « channel."
set say(lang.1.1706)   "error: there is already a command with name/alias «."

in fisierul a&a_40_a_stats.tcl

cauti
	puts $file "\n#Disabled local & global commands\n"
	puts $file "[a:command -array]"
	
si faci sa arate

	puts $file "\n#Disabled local & global commands\n"
	puts $file "[a:command -array]"
			
	puts $file "\n#Aliases for commands\n"
	puts $file "[alias -array]"		
	
in fisierul a&a_01_core.tcl cauti 

	set option  [lindex $arg 0]
	set chan1st $chan
	
si adaugi sub ele

	set comm [alias -check $chan $comm]
	
tot in a&a_01_core.tcl adaugi procesul de alias

proc alias {cmd {chan ""} {c ""} {a ""}} {
	global alias
	
	set chan  [string tolower $chan] 
	set c	 [string tolower $c]
	set a	 [string tolower $a]
	
	switch -exact -- $cmd {
		-exists { return [info exists alias($chan,$c)]}
		-check  { if { [info exists alias($chan,$c)]} {return $alias($chan,$c)} else {return $c} }
		-list   { set temp ""; foreach w [array names alias $chan,*] {lappend temp "$w $alias($w)," ; regsub -all -nocase -- $chan, $temp "" temp}; return [string trimright [join $temp] ,] }
		-number { set number 0 ; foreach w [array names alias $chan,*] {incr number}; return $number}
		-add	{ set alias($chan,$a) $c}
		-array  { return[list array set alias [array get alias]]} 
		-clean  { catch {array unset alias $chan,* }}
		-remove { catch {unset alias($chan,$c)}}		
		default { return 0 }
	
	}

}

Last edited by AdrianK; 13-07-2005 at 18:39.
AdrianK is offline   Reply With Quote