| View previous topic :: View next topic |
| Author |
Message |
Longbow Voice
Joined: 13 Jan 2005 Posts: 29
|
Posted: Sun Oct 23, 2005 7:23 pm Post subject: Two scripts, which is better? |
|
|
| Code: | bind pub - ${trigger}kick akick
proc akick {nick host hand chan text} {
global botnick protect
if {([matchattr $hand n] || [isop $nick $chan]) && [isop $botnick $chan]} {
if {[lindex $text 0] == ""} {
putserv "NOTICE $nick :You need to enter a user."
} else {
if {[onchan [lindex $text 0] $chan]} {
if {([string tolower [lindex $text 0]] == [string tolower $botnick]) || [matchattr [lindex $text 0] +n]} {
putserv "NOTICE $nick :That user is protected."
} else {
if {[lindex $text 1] == ""} {
putquick "KICK $chan [lindex $text 0] Bye."
} else {
putquick "KICK $chan [lindex $text 0] [lrange $text 1 end]"
}
}
} else {
putserv "NOTICE $nick :[lindex $text 0] is not on the channel."
}
}
}
} |
| Code: | bind pub - ${trigger}kick akick
proc akick {nick host hand chan text} {
global botnick
if {([matchattr $hand n] || [isop $nick $chan]) && [botisop $chan]} {
global botnick
if {$text == ""} {
putserv "NOTICE $nick :You need to enter a user."
return 0
}
if {![onchan [lindex $text 0] $chan]} {
putserv "NOTICE $nick :[lindex $text 0] is not on the channel."
return 0
}
if {([string tolower [lindex $text 0]] == [string tolower $botnick]) || [matchattr [lindex $text 0] +n]} {
putserv "NOTICE $nick :That user is protected."
return 0
}
if {[lindex $text 1] == ""} {
putquick "KICK $chan [lindex $text 0] Bye."
} else {
putquick "KICK $chan [lindex $text 0] [lrange $text 1 end]"
}
return 0
}
} |
Both do the same action, but was wondering which is "better"? |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun Oct 23, 2005 9:02 pm Post subject: |
|
|
well both suck because they are posted with bad formating plus both use list functions on strings (read http://forum.egghelp.org/viewtopic.php?t=2603).
Other than that I dont see a major diffrence, seems the if structure is a bit diffrent, but almost unrecognizeable without formating. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Tue Oct 25, 2005 7:48 am Post subject: |
|
|
| Code: |
bind PUB o|mn ${trigger}kick trigger:kick
proc trigger:kick {nickname hostname handle channel arguments} {
if {[botisop $channel]} {
if {[lindex [split $arguments] 0] == "" || ![onchan [lindex [split $arguments] 0] $channel] || [string equal -nocase $nickname [lindex [split $arguments] 0]] || [isbotnick [lindex [split $arguments] 0]] || [string length [lindex [split $arguments] 0]] == "1"} {
putquick "NOTICE $nickname :Usage: ${::lastbind} nickname ?reason?"
} elseif {[validuser [nick2hand [lindex [split $arguments] 0]]] && (([matchattr [nick2hand [lindex [split $arguments] 0]] |o $channel] && ![matchattr $handle |m $channel]) || ([matchattr [nick2hand [lindex [split $arguments] 0]] |m $channel] && ![matchattr $handle |n $channel]))} {
putquick "KICK $channel $nickname :Do not attempt to kick someone with a higher or equal level to you."
} else {
putquick "KICK $channel [string trim [lindex [split $arguments] 0]] :[expr {([join [string trim [lrange [split $arguments] 1 end]]] == "") ? "Requested by $handle." : "[join [lrange [split $arguments] 1 end]]"}]"
}
}
} |
(Code looks nasty in the browser because it has to cut it into pieces) |
|
| Back to top |
|
 |
|