| View previous topic :: View next topic |
| Author |
Message |
cache Master
Joined: 10 Jan 2006 Posts: 306 Location: Mass
|
Posted: Thu Jul 08, 2010 3:06 pm Post subject: userlist to msg [SOLVED] |
|
|
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: |
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 |
|
| Back to top |
|
 |
username Op

Joined: 06 Oct 2005 Posts: 196 Location: Russian Federation, Podolsk
|
Posted: Thu Jul 08, 2010 3:36 pm Post subject: |
|
|
You need to read about binds here: http://www.eggheads.org/support/egghtml/1.6.20/tcl-commands.html#binda
In bind msg there is no chan.
And you need not use before , because you can use lappend for non exists variable and this variable will be created. You post very strange code. Try it:
| Code: | 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/ |
|
| Back to top |
|
 |
cache Master
Joined: 10 Jan 2006 Posts: 306 Location: Mass
|
Posted: Thu Jul 08, 2010 4:13 pm Post subject: |
|
|
| Tried that but still get error Tcl error [msg:userlist]: wrong # args: should be "msg:userlist nick uhost hand chan text" |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Thu Jul 08, 2010 4:59 pm Post subject: |
|
|
| Code: | 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* _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
cache Master
Joined: 10 Jan 2006 Posts: 306 Location: Mass
|
Posted: Thu Jul 08, 2010 6:25 pm Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri Jul 09, 2010 5:08 am Post subject: |
|
|
| Code: | 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  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
cache Master
Joined: 10 Jan 2006 Posts: 306 Location: Mass
|
Posted: Fri Jul 09, 2010 7:49 am Post subject: |
|
|
| 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 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. |
|
| Back to top |
|
 |
username Op

Joined: 06 Oct 2005 Posts: 196 Location: Russian Federation, Podolsk
|
Posted: Sat Jul 10, 2010 2:01 am Post subject: |
|
|
Oh, sorry about chan in msg bind. It was my "epic fail". _________________ Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/ |
|
| Back to top |
|
 |
|