egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Two scripts, which is better?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Longbow
Voice


Joined: 13 Jan 2005
Posts: 29

PostPosted: Sun Oct 23, 2005 7:23 pm    Post subject: Two scripts, which is better? Reply with quote

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
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Oct 23, 2005 9:02 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Tue Oct 25, 2005 7:48 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber