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.

userlist to msg [SOLVED]

Help for those learning Tcl or writing their own scripts.
Post Reply
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

userlist to msg [SOLVED]

Post by cache »

Trying to get this command to work in pm, what am I doing wrong with the proc?? log file just keeps saying should be {nick uhost hand chan text}, can someone please show me correct way? Thanks

Code: Select all

bind msg f|f !userlist msg:userlist 

proc msg:userlist {nick uhost hand chan text} { 
  if {[userlist | $chan] == ""} { 
    putserv "PRIVMSG $nick :Userlist empty for $chan." 
  } else { 
    set tmp "" 
    foreach user [userlist | $chan] { 
      lappend tmp $user 
      if {[llength $tmp] == "6"} { 
        putserv "PRIVMSG $nick :[join $tmp ", "]." 
        set tmp "" 
      } 
    } 
    if {[llength $tmp] != "6"} { 
      putserv "PRIVMSG $nick :[join $tmp ", "]." 
      set tmp "" 
    } 
    putserv "End of userlist." 
  } 
}


Last edited by cache on Fri Jul 09, 2010 7:50 am, edited 1 time in total.
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

You need to read about binds here: http://www.eggheads.org/support/egghtml ... html#binda
In bind msg there is no chan.
And you need not use

Code: Select all

set tmp ""
before

Code: Select all

lappend tmp $user
, because you can use lappend for non exists variable and this variable will be created. You post very strange code. Try it:

Code: Select all

bind msg f|f !userlist msg:userlist

proc msg:userlist {nick uhost hand chan text} {
    if {[userlist $chan] == ""} {
        putserv "PRIVMSG $nick :Userlist empty for $chan."
    } else {
    foreach user [userlist $chan] {
        lappend tmp $user
    }
    putserv "PRIVMSG $nick :[join $tmp ", "]."
    putserv "End of userlist."
  }
} 
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

Tried that but still get error Tcl error [msg:userlist]: wrong # args: should be "msg:userlist nick uhost hand chan text"
User avatar
CrazyCat
Revered One
Posts: 1334
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

username wrote:You need to read about binds here: http://www.eggheads.org/support/egghtml ... html#binda
In bind msg there is no chan.
So, your proc must be:

Code: Select all

proc msg:userlist {nick uhost hand text} { 
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

variable nicks_per_line 5

bind msg f|f !userlist msg:userlist

proc msg:userlist {nick uhost hand text} {
  set chan [lindex [split $text] 0]
  if {![validchan $chan]} {
    putserv "PRIVMSG $nick :$chan is not valid."
  } elseif {![botison $chan]} {
    putserv "PRIVMSG $nick :I am not on $chan."
  } elseif {![string length [userlist | $chan]} {
    putserv "PRIVMSG $nick :The userlist for $chan is empty."
  } else {
    foreach user [userlist | $chan] {
      lappend spam $user
      if {[llength $spam] >= $::nicks_per_line} {
        putserv "PRIVMSG $nick :[join $spam ", "]."
        unset spam
      }
    }
    if {[info exists spam]} {
      putserv "PRIVMSG $nick :[join $spam ", "]."
    }
    putserv "End of userlist."
  }
}
Maybe smth like this? ;)
<nick> !userlist #mychan
<bot> *insert spam here*
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

Thank you, I do get an error that a close bracket is missing,trying to figure out where it goes lol.... so no way to have it without having to use #mychan?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

variable nicks_per_line 5
variable chan_for_this #mychan

bind msg f|f !userlist msg:userlist

proc msg:userlist {nick uhost hand text} {
  if {![string length [set chan [lindex [split $text] 0]]]} {
    set chan $::chan_for_this
  }
  if {![validchan $chan]} {
    putserv "PRIVMSG $nick :$chan is not valid."
  } elseif {![botonchan $chan]} {
    putserv "PRIVMSG $nick :I am not on $chan."
  } elseif {![string length [userlist | $chan]} {
    putserv "PRIVMSG $nick :The userlist for $chan is empty."
  } else {
    foreach user [userlist | $chan] {
      lappend spam $user
      if {[llength $spam] >= $::nicks_per_line} {
        putserv "PRIVMSG $nick :[join $spam ", "]."
        unset spam
      }
    }
    if {[info exists spam]} {
      putserv "PRIVMSG $nick :[join $spam ", "]."
    }
    putserv "End of userlist."
  }
}
This one, if you don't put a channel, it will use the hardcoded variable chan_for_this as your channel. This fixes the bracket issue as well. This should work for ya ;)
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

speechles wrote: This one, if you don't put a channel, it will use the hardcoded variable chan_for_this as your channel. This fixes the bracket issue as well. This should work for ya ;)
Thank you, it helps :D I guess it isn't possible to make $chan work in pm w/o having to hardcode the channel in, so I assume only commands in open room know what the roomname is but pm don't.
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

Oh, sorry about chan in msg bind. It was my "epic fail".
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
Post Reply