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.

Bind dcc - voice

Help for those learning Tcl or writing their own scripts.
Post Reply
n
neoclust
Halfop
Posts: 55
Joined: Fri Aug 14, 2009 11:03 am

Bind dcc - voice

Post by neoclust »

Everything is in the title please i want a script that voice in mass in dcc

ex: .+v nick1 nick2 nick3 nick4 nick5 nick6 #channel
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

Code: Select all

 proc dcc:+v {hand idx text} {
  set chan [join [lrange [split $text] end end]]
  set vnicks [join [lrange [split $text] end-1 end-1]]
  if {$vnicks == ""} {
   putidx $idx "Usage: +v <nicknames ...> \[#channel\]"
   return 1
  }
   if {([regexp {^#} $chan])&&(![validchan "$chan"])} {
    if {(![validchan [lindex [split [console $idx]] 0]])} {
    putidx $idx "Usage: +v <nicknames ...> \[#channel\]"
    return 1
    } else {
     set chan [lindex [split [console $idx]] 0]
    }
   }
    if {![botisop $chan]} {
     putidx $idx "Sorry, I'm not a channel operator on $chan"
     return 1
    }
     foreach nicks $vnicks {
      pushmode $chan +v $nicks
     }
      return 1
 }

 bind dcc o|- +v dcc:+v
* Not Tested, any problems please post reply.
n
neoclust
Halfop
Posts: 55
Joined: Fri Aug 14, 2009 11:03 am

Post by neoclust »

Thanks man i made this code but it does not work as it should, thank you filed this procedure I'll test it.

Code: Select all

bind dcc n +v mass:voice
proc mass:voice {hand idx arg} {
     set nick1 [lindex $arg 0]
     set nick2 [lindex $arg 2]
     set nick3 [lindex $arg 3]
     set nick4 [lindex $arg 4]
     set nick5 [lindex $arg 5]
     set nick6 [lindex $arg 6]
     set nick7 [lindex $arg 7]
     set chan "#chan"
     foreach nick [list $nick1 $nick2 $nick3 $nick4 $nick5 $nick6 $nick7] { pushmode $chan +v $nick }
}
n
neoclust
Halfop
Posts: 55
Joined: Fri Aug 14, 2009 11:03 am

Post by neoclust »

when I forget to put the #channel on the line I get it
(me): .+v angel Fury
((bot): [12:57] Tcl error [dcc:+v]: illegal channel: cryp
it should print some other exception I suppose, Ex: please put the channel name instead of "Tcl error [dcc:+v]: illegal channel: Fury" and
I noticed that the bot does not voice the entire list just one nick
Thanks
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Tcl_no_tk:
Just a few remarks;
vnicks is a string, not a list. Thus not suitable for use with foreach.
[join [lrange [split $text] end end]] is the same as [lindex [split $text] end], same goes for end-1.
If the last word is not a valid channel, wouldn't this be a nickname to voice then? (add it to the list of nicks to voice)
The console command returns a list, not a string. Don't use split here.

I'd write the script somewhat like this:

Code: Select all

proc dcc:pv {handle idx text} {
 set list [split $text]
 if {[validchan [lindex $list end]]} {
  set channel [lindex $list end]
  set list [lrange $list 0 end-1]
 } elseif {[validchan [lindex [console $idx] 0]]} {
  set channel [lindex [console $idx] 0]
 } else {
  putidx $idx {Usage: +v <nickname> [nickname] ... [channel]}
  return 1
 }
 if {![botonchan $channel] || ![botisop $channel]} {
  putidx $idx "I am currently not a channel operator on $channel"
 }
 foreach vnick [lsort -unique $list] {
  pushmode $channel +v $vnick
 }
}
bind dcc o|o +v dcc:pv
This could be more optimized, but I've kept it like this to make it easier to follow the flow of the code.
NML_375
n
neoclust
Halfop
Posts: 55
Joined: Fri Aug 14, 2009 11:03 am

Post by neoclust »

Thanks dude it's fine
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

nml375: thanks! :)
Post Reply