Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: alias

  1. #1
    Member Freezed's Avatar
    Join Date
    Oct 2004
    Age
    29
    Posts
    171
    Rep Power
    0

    Default alias

    aqwzsx, imi poti da un exemplu cum as putea sa fac alias ? ca vreau sa incerc :)

  2. #2
    Member lsn's Avatar
    Join Date
    Jun 2004
    Location
    In the NeXuS
    Posts
    161
    Rep Power
    92

    Default alias

    sa revenim la alias
    sa presupunem ca am in felul urmator la comanda voice facem alias v
    si in momentul asta am salvat aliasul de forma
    Code:
    alias(#chan,v) voice|v
    in parser am pus ceva de genu
    Code:
    if {[info exists alias($chan,$comm)]} {.....}
    aici e problema am incercat mai multe variante nici nu mai stiu exact care si in momentul cand dadeam v in dcc imi aparea invalid command "voice"
    apoi am incercat sa adaug comanda cu
    Code:
    command -add [lindex [split $alias($chan,$comm) |] 1] $com([lindex [split $alias($chan,$comm)] 0],$proc) .....
    in momentul cand ii dadeam info despre v imi zicea corect despre voice dar cand dadeam comanda v imi aparea in dcc invalid command "1"
    .......... poate imi dai alta idee ?

    PS: folosesc procese din a&a light in scriptul vechi de aceea apar asa setarile la mine

  3. #3
    Administrator

    aka aqwzsx

    Join Date
    Jun 2004
    Posts
    853
    Blog Entries
    130
    Rep Power
    3

    Default

    data viitoare, cand ai asa gen de intrebari, te rog mult
    1. sa dai codul complet, fara puncte puncte
    2. sa eviti fraze de genul "am incercat mai multe variante nici nu mai stiu exact care" si sa dai varianta concreta care corespunde erorii/problemei specificate.
    revenind la alias :) ai putea sa fii putin mai creativ si ai rezolva problema sigur :P deci salvam alias in forma
    Code:
    alias(#chan,v) voice
    in parser adaugam un singur rand
    Code:
    set command check:alias $chan $command
    si procesul check:alias ar arata asa
    Code:
    proc check:alias {chan command} { 
    global alias
     
    
    if { [info exists alias($chan,$command)]} {return $alias($chan,$command)]} else {return $command}
    }
    Cam e simplu codul dar lucreaza :P sper sa propui o alta varianta sau sa improvizezi pe seama acestei care am dat numai ce, mi-ar fi interesant sa vad ce rezultate ai. In cazul specificat mai sus, realizezi ca si help, usage etc etc, totul va lucra automat fara nici o modificare, nu e nevoie de alte modificari in script, sa adaugi noi comenzi etc etc :) ramane pur cum si era conceput, doar un alias.

    Lucrurile sunt simple in programare si cred ca cel mai important este simplicitatea si creativitatea ;)

  4. #4
    Member lsn's Avatar
    Join Date
    Jun 2004
    Location
    In the NeXuS
    Posts
    161
    Rep Power
    92

    Default

    Code:
    a:command -add alias	 pub:alias			 1132 626 |N
    
    proc pub:alias {hand chan args x mix} {
    	
    	set comm [lindex $args 0]
    	set aka  [lindex $args 1]
    	
    	if {![string length $comm]}		 { usage $x alias; return "FAILED: not all paramatres specified"}
    	if { [regexp {^(-remove|-r)$} $comm] && $aka!=""} {if {[string equal -nocase all $aka]} {alias -clean $chan; tell $x 346 ; return "removed all"} {if {![alias -exists $chan $aka]} {tell $x 343 $aka; return "no such alias ($aka)"} {tell $x 344 $aka; alias -remove $chan $aka; return "removed $aka"}}}
    	if { [regexp {^(-list|-l)$} $comm]} {set list [alias -list $chan]; if {![llength $list]} {tell $x 348 $chan; return "failed empty"} {tell $x 17 $list; return $list}}
    	if {![a:command -exists $comm]}	 {tell $x 18 $comm; return "FAILED: invalid command specified ($comm)"}
    	if {![string length $aka]}		 { usage $x alias; return "FAILED: not all paramatres specified"}
    	if { [command -exists $aka] || [alias -exists $chan $aka]} {tell $x 283 $aka; return "failed already exists a command name/alias $aka"}
    	if { [alias -number $chan] >= 15}   {tell $x 347; return "failed already have 15 aliases"}
    	
    	alias -add $chan $comm $aka
    	
    	tell $x 345 "$aka $comm"
    	
    	return "$comm" 
    }
    Code:
    set say(lang.1.283)   "FAILED: there is already a command with name/alias ."
    set say(lang.1.343)   "FAILED: i have no info about %B%B alias ..."
    set say(lang.1.344)   "Removed %B%B alias ..."
    set say(lang.1.345)   "Added %r%% as alias for command %b%%."
    set say(lang.1.347)   "FAILED: You can only set 15 aliases."
    set say(lang.1.346)   "Removed all aliases."
    set say(lang.1.348)   "FAILED: No alias defined for  channel."
    set say(lang.1.626)   "USAGE: alias \[-remove|-list\] <command> <alias> \[all\] "
    set say(lang.1.1132)  "HELP: Define any ALIAS to any BOT command (you can specify up to 15 aliases per chan)"
    in proc a:parser modifici
    Code:
    if { [string match "#*" $option]} {set args [lrange $arg 1 end]; set chan $option} { set args $arg}
    if {![a:command -exists $comm]} {return} elseif { [a:command -inactive $comm $chan]} {return}
    in

    Code:
    if { [string match "#*" $option]} {set args [lrange $arg 1 end]; set chan $option} { set args $arg}
    set comm [alias -check $chan $comm]
    if {![a:command -exists $comm]} {return} elseif { [a:command -inactive $comm $chan]} {return}
    si ca sa iti salveze aliasurile in a&a_40_a_stats.tcl

    cauti
    Code:
    puts $file "\n#Disabled local & global commands\n"
    puts $file "[a:command -array]"
    si modifici in
    Code:
    puts $file "\n#Disabled local & global commands\n"
    puts $file "[a:command -array]"
    
    puts $file "\n#Aliases for commands\n"
            puts $file "[alias -array]"
    cam asta ar fi tot sper ca nu am uitat nimic :p

  5. #5
    Member
    Join Date
    Jun 2004
    Location
    Canada
    Age
    27
    Posts
    174
    Rep Power
    0

    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 17:39.

  6. #6
    Member Freezed's Avatar
    Join Date
    Oct 2004
    Age
    29
    Posts
    171
    Rep Power
    0

    Default

    Dupa restart aliasurile nu mai merg. De salvat le salveaza, dar nu mai merg.

  7. #7
    Member lsn's Avatar
    Join Date
    Jun 2004
    Location
    In the NeXuS
    Posts
    161
    Rep Power
    92

    Default

    da ai dreptate, procesul de alias era compatibil cu scriptul vechi
    nu mai merg dupa restart pentru ca dupa restart se pierd
    Ca sa se evite acest lucru trebuie declarat alias ca variabila global in a&a_40_a_stats.tcl mai precis la procesul channel {....

    Code:
    -load{ global comm; variable infofile; channel -unload; if {![catch {source $infofile}]} {return 1} {return 0}}
    inlocuit cu
    Code:
    -load{ global comm alias; variable infofile; channel -unload; if {![catch {source $infofile}]} {return 1} {return 0}}
    acuma va merge TESTAT/VERIFICAT OK

  8. #8
    Junior Member UtahEdu's Avatar
    Join Date
    Feb 2005
    Age
    39
    Posts
    3
    Rep Power
    0

    Exclamation Alias

    am facut exact ca voi dar uite ce face scriptul da niste errori deci merge pe canal numai ca la fiecare ora cand salveaza el da erroarea asta :

    1. ERROR (Jun 27 09:00): FAILED to write info file, error: invalid command name "returnarray set alias {#master.ro,s save #nospam,r rehash}"

    ce si unde mai trebuie modif ca nu reusesc.

  9. #9
    Member lsn's Avatar
    Join Date
    Jun 2004
    Location
    In the NeXuS
    Posts
    161
    Rep Power
    92

    Default

    ceva nu ai facut bine vezi sa nu uiti spatiile corespunzatoare
    Code:
    -array { return	[list array set alias [array get alias]]}

  10. #10
    Junior Member UtahEdu's Avatar
    Join Date
    Feb 2005
    Age
    39
    Posts
    3
    Rep Power
    0

    Thumbs up AI dreptate

    Isn ai dreptate de la spatiu era dar de aici:

    eu am scris:

    if {![a:command -exists $comm]} {a:tell $x 18 $comm; return "FAILED: invalid command specified ($comm)"}

    si trebuia :
    if {![a:command -exists $comm]} _________{a:tell $x 18 $comm; return "FAILED: invalid command specified ($comm)"}

    linia_____ reprezinta spatiu lipsa care eu nu l-am pus
    Mercic.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •