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 

userlist to msg [SOLVED]

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


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Thu Jul 08, 2010 3:06 pm    Post subject: userlist to msg [SOLVED] Reply with quote

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
View user's profile Send private message
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Thu Jul 08, 2010 3:36 pm    Post subject: Reply with quote

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
Code:
set tmp ""
before
Code:
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:
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
View user's profile Send private message Send e-mail Visit poster's website
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Thu Jul 08, 2010 4:13 pm    Post subject: Reply with quote

Tried that but still get error Tcl error [msg:userlist]: wrong # args: should be "msg:userlist nick uhost hand chan text"
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Thu Jul 08, 2010 4:40 pm    Post subject: Reply with quote

username wrote:
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.

So, your proc must be:
Code:
proc msg:userlist {nick uhost hand text} {

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Thu Jul 08, 2010 4:59 pm    Post subject: Reply with quote

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? Wink
<nick> !userlist #mychan
<bot> *insert spam here*
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Thu Jul 08, 2010 6:25 pm    Post subject: Reply with quote

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


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Jul 09, 2010 5:08 am    Post subject: Reply with quote

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 Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Fri Jul 09, 2010 7:49 am    Post subject: Reply with quote

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 Wink


Thank you, it helps Very Happy 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
View user's profile Send private message
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Sat Jul 10, 2010 2:01 am    Post subject: Reply with quote

Oh, sorry about chan in msg bind. It was my "epic fail".
_________________
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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