This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

!zline

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
l
lolwutxd
Voice
Posts: 3
Joined: Mon Apr 05, 2010 2:33 am

!zline

Post by lolwutxd »

Hello,

I have the following code but I want to add to it

bind pub n !zline zline
proc zline { nickname hostname handle channel arguments } {
set nick [string tolower [lindex $arguments 0]]
set reason [lrange [split $arguments] 1 end]
putquick "gzline $nick :$reason"
putquick "privmsg $channel :Added a \002Global Zline\002 for $nick With The Reason $reason"
}

At the moment I can just enter !zline and it will reply back with

"<BotNick> Added a Global Zline for With The Reason"

I want to make it so you need to either provide a IP address OR a nickname AND with a reason or it will back with a error message like

"Sorry can't I didnt find a reason to zline with."

Thanks
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

First off,
Your use of lindex is improper at best; this command expect the first input to be a list, just like lrange. Further, lrange returns a list, not a string, so you'll want to convert it back into a string using join.

Next, you'll need to add a test to see whether the user supplied both arguments or not. You could either do this by testing if either $nick or $reason is the empty string, or test the number of elements in $arguments - after you've converted it into a list; if this is less than 2, atleast one argument is missing:

Code: Select all

bind pub n !zline zline
proc zline {nickname hostname handle channel arguments} {
  set items [split $arguments]
  if {[llength $items] < 2} {
    puthelp "PRIVMSG $channel :Sorry, can't find a reason to zline with."
    return
  }
  set nick [lindex $items 0]
  set reason [join [lrange $items 1 end]]
  putquick "GZLINE $nick :$reason"
  puthelp "PRIVMSG $channel :Added a \002Global Zline\002 for $nick with the reason $reason"
}
NML_375
Post Reply