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.

Getall nicknames in channel

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
M
MrDeNNiS
Voice
Posts: 3
Joined: Sat Jan 07, 2012 9:56 am

Getall nicknames in channel

Post by MrDeNNiS »

Hello,

I was using mirc and this code was working perfectly.

Code: Select all

on me:*:join:#:{ 
  set %activate $true 
  who # 
} 
on $*:text:.call*:#:{ 
  if !$(,$+(%,t,.,#)) { 
    inc -u3 $+(%,t,.,#) 
    .msg # $getall 
  }
  msg $chan >>>>> 0,4$2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 
} 
raw *:*:{ 
  if %activate { 
    if $numeric = 352 { 
      hadd -m all $2 $addtok($hget(all,$2),$6,44) 
    } 
    elseif $numeric = 315 { 
      msg $2 $& 
        $replace($hget(all,$2),$chr(44),$+($chr(44),$chr(32))) 
      unset %activate 
    } 
  } 
} 
alias getall { 
  while $nick(#,$0) { tokenize 32 $1- $v1 } 
  $iif($isid,return,echo -aegt) $& 
    $replace($2-,$chr(32),$+($chr(44),$chr(32))) 
}
Image

I passed to eggdrop and i dont know TCL, can anyone help me please?
User avatar
CrazyCat
Revered One
Posts: 1303
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Quite simple, here is an example giving userlist with their status in chan :

Code: Select all

bind pub - "!chan" chan:list

proc chan:list {nick uhost handle chan arg} {
    set ulist ""
    set cusr 0
    foreach user [chanlist $::crelay::me(chan)] {
        if { $user == $::botnick } { continue; }
        if { [isop $user $::crelay::me(chan)] == 1 } {
            set st "@"
        } elseif { [ishalfop $user $::crelay::me(chan)] == 1 } {
            set st "%"
        } elseif { [isvoice $user $::crelay::me(chan)] == 1 } {
            set st "%"
        } else {
            set st ""
        }
        incr cusr 1
        append ulist " $st$user"
        if { $cusr == 5 } {
            putserv "PRIVMSG $chan :$ulist"
            set ulist ""
            set cusr 0
        }
    }
    if { $ulist != "" } {
    putserv "PRIVMSG $chan :$ulist"
    }
}
M
MrDeNNiS
Voice
Posts: 3
Joined: Sat Jan 07, 2012 9:56 am

Post by MrDeNNiS »

Hello,

I'm getting this error, please help.

Code: Select all

[12:25:19] Tcl error [chan:list]: can't read "::crelay::me(chan)": no such variable
J
Johannes13
Halfop
Posts: 46
Joined: Sun Oct 10, 2010 11:38 am

Post by Johannes13 »

Ok, I don't know why he uses this wired variables, stripped, should work

Code: Select all

bind pub - "!chan" chan:list

proc chan:list {nick uhost handle chan arg} {
    set ulist ""
    set cusr 0
    foreach user [chanlist $chan] {
        if { $user == $::botnick } { continue; }
        if { [isop $user $chan] == 1 } {
            set st "@"
        } elseif { [ishalfop $user $chan] == 1 } {
            set st "%"
        } elseif { [isvoice $user $chan] == 1 } {
            set st "%"
        } else {
            set st ""
        }
        incr cusr 1
        append ulist " $st$user"
        if { $cusr == 5 } {
            putserv "PRIVMSG $chan :[join $ulist { }]"
            set ulist ""
            set cusr 0
        }
    }
    if { $ulist != "" } {
    putserv "PRIVMSG $chan :[join $ulist { }]"
    }
}
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

Or, for a simplistic method

Code: Select all

bind pub - .call call:proc
proc call:proc {nick uhost hand chan arg} {
  global botnick
# check if user has access to bot or not
  if {![matchattr [nick2hand $nick] o|o $chan]} {return}
  set nicklist [chanlist $chan]
# removing botnick from list
  set notbot [lsearch $nicklist $botnick]
  set nicklist [lreplace $nicklist $notbot $notbot]
# removing nickname that triggered event
  set notnick [lsearch $nicklist $nick]
  set nicklist [lreplace $nicklist $notnick $notnick]
  putquick "PRIVMSG $chan :$nicklist"
  putquick "PRIVMSG $chan :>>>>> \0030,4$arg\003"
}
It's easy to edit which parts you don't want to check, by adding a #
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You can remove the:

Code: Select all

if {![matchattr [nick2hand $nick] o|o $chan]} {return} 
line and replace the bind line with:

Code: Select all

bind pub o|o .call call:proc 
I don't understand why one doesn't use the already built in functions, for example:

Code: Select all

if { $user == $::botnick } { continue; } 
that can be replaced by the isbotnick function:

Code: Select all

if {[isbotnick $user]} continue
Notice the lack of {}, as it means that only one command can and will be triggered if that if statement is true.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

caesar, I code the way I code, I've taught myself and I don't think my methods will change. There are a lot of functions I don't use, know of, or even understand, so I keep it simple and know it works.
I didn't add flags to a bind because I like to use matchattr.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
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

#---WONDERFUL NICKLIST
# Wonderful world of what it is, there is nothing
# more wonderful than wonderful is. The wonderful
# script by ... egghelp ... the wonderful place.

#--- config starts here---
# Amount of nicks to put on each line as a maximum.
set callNickPerLine 20

# effect to add to the bots nick, put colors etc, go crazy.
set callBotEffect "\002"

# effect to add to the nickname triggering the call, again go nuts.
set callNickEffect "\037"

#--- script starts here ---
bind pub - .call proc:call

proc proc:call {n u h c t} {
	# iterate nicklist to pretty up with +%@ channel modes
	foreach nick [chanlist $c] {
		# make a new list, wrapping with the new modes and prettying it up
		lappend withmode [proc:figure:out [proc:mode $nick $c]]
	}
	return [proc:call:out $withmode $c $t]
}

# adds the appropriate effect to botnick or nick triggering
proc proc:figure:out {t} {
	if {[isbotnick $nick]} {
		return "$::callBotEffect$t\017"
	} elseif {[string equal -nocase $nick $t]} {
		return "$::callNickEffect$t\017"
	} 
	return $t
}

# adds the appropriate channel mode +%@ to the nick
# a nickname can have MORE than one mode set on it
proc proc:mode {n c} {
	set mode ""
	if {[isvoice $n $c]} { append mode "+" }
	if {[ishalfop $n $c]} { append mode "%" }
	if {[isop $n $c]} { append mode "@" }
	return $mode$n
}

# outputs the pretty new nicklist with each line having the number of nicks you set above
proc proc:call:out {t c s} {
	for {set x 0} {x < [llength $t]} {incr x [expr {$::callNickPerLine -1}] } {
		putserv "privmsg $c :[join [lrange $go $x [expr {$x + ($::callNickPerLine -1)}]]]"
	}
	putserv "privmsg $c :>>>>> $s"
	# change to "return 1"
	# if you wish not to block this command on other scripts.
	return 0
}
This is more, what you would see if you want to make something simple look more than it is. This is an example of style versus simplicity. At what point do the two coexist? The answer is, they never do. :)

Edit: fixed.
Last edited by speechles on Wed Feb 08, 2012 1:31 pm, edited 2 times in total.
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

Nice
Last edited by Get_A_Fix on Wed Feb 08, 2012 5:18 am, edited 1 time in total.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I got to admit that Get_A_Fix's method of removing the bot from the nick list is much better than having a isbotnick check inside a foreach loop.

Code: Select all

} elseif {[string equal -nocase $nick $n]} {
Shouldn't $n be a $t? :) Also, elseif statements should be better suited instead of plain if statements in the proc:mode function, or at least append that mode to mode variable if you wish to check if the user has two or multiple modes set, or leave it as it is if you wish to display only the highest one.
Once the game is over, the king and the pawn go back in the same box.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

caesar wrote:I got to admit that Get_A_Fix's method of removing the bot from the nick list is much better than having a isbotnick check inside a foreach loop.
Not for me, this removes the bots nick from the channel list. The bot is in the channel. This is incorrect. This is lying. My method highlights the bots nick. My method is accurate and honest.
caesar wrote:

Code: Select all

} elseif {[string equal -nocase $nick $n]} {
Shouldn't $n be a $t? :)
Yes, i fixed that miniscule mistake.
caesar wrote:Also, elseif statements should be better suited instead of plain if statements in the proc:mode function, or at least append that mode to mode variable if you wish to check if the user has two or multiple modes set, or leave it as it is if you wish to display only the highest one.
No, those MUST be left as individual if statements. A user can have MORE than one mode set. This is how it is intended. Your method is flawed. It is not accurate nor honest. It is lying, which I won't do.

---

Now, don't get me wrong. There are several ways to skin a cat. But when a poacher approaches you, and tells you that there are better ways to skin your cat and he can show you how. It appears condescending and low.
For example: Shouldn't $n be a $t? :) <-- do you notice the smiley? It's there as a "neener neener" for no other reason.

This is something equated with those who can't feel good about themselves, without making others feel bad. In this case, nit-picking and mis-understanding concepts has me feeling like some forum members always "just talk" and sit back on their laurels. They never provide any code of their own, just rip apart other peoples. Judge not, lest ye be judged. Keep this in mind. This is whats happening right now.. :P

It doesn't matter what you like, or how you want things. The original posters question is the focus of this thread. Not trying to fit your whims..
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

speechles wrote:The original posters question is the focus of this thread.
That was what I was going for. He asked for things a certain way, I made it how he wanted it, but gave options that could have been commented out; like the botnick or nick triggering event. My code would have choked if it was triggered on a large channel, I would need to split and have a newline.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
v
visual
Voice
Posts: 3
Joined: Tue Feb 21, 2012 10:50 am

List users on specified channel

Post by visual »

Hi, while all this scripts posted here shows the current userlist on the current channel window opened. Can someone recode the script so the bot will show the userlist on the specified channel? like !chan <#channel> on public window. Thanks.
jm
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Re: List users on specified channel

Post by Get_A_Fix »

visual wrote:Hi, while all this scripts posted here shows the current userlist on the current channel window opened. Can someone recode the script so the bot will show the userlist on the specified channel? like !chan <#channel> on public window. Thanks.
Command trigger ".who #channel"

Code: Select all

bind pub - .who who:proc
proc who:proc {nick uhost hand chan text} {
    global botnick
    # check if user has access to bot or not
    if {[matchattr $hand o|o $chan]} {
        # check if a single argument given
        if {[llength [split $text]] == 1} {
            # check if the single argument could be a channel name
            if {[regexp -- {^#} $text]} {
                # check if the bot has a channel record
                if {[validchan $text]} {
                    # check if bot is on the channel
                    if {[botonchan $text]} {
                        set nicklist [chanlist $text]
                        # removing botnick from the nicklist
                        if {[set bot [lsearch $nicklist $botnick]] != -1} {set nicklist [lreplace $nicklist $bot $bot]}
                        # loop to split output into 20 nicks per line in case of large channels
                        while {[llength $nicklist] != 0} {
                            set output [lrange $nicklist 0 19]
                            putserv "PRIVMSG $chan :[join $output]"
                            set nicklist [lrange $nicklist 20 end]
                        }
                    } else {putserv "PRIVMSG $chan :ERROR\: Bot is not currently monitoring $text"}
                } else {putserv "PRIVMSG $chan :ERROR\: Bot does not have a channel record for $text"}
            } else {putserv "PRIVMSG $chan :ERROR\: $text is not a legal channel name"}
        } else {putserv "PRIVMSG $chan :ERROR\: Correct syntax .who #channel"}
    }
    return 0
}
A big thanks goes out to arfer (you know who you are), for lending a hand and making this code proficient.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Instead of

Code: Select all

if {[llength [split $text]] == 1} { 
you should use scan like this:

Code: Select all

if {[scan $text %s channel] != 1} { 
cos this grabs and creates variable channel from the user's input. Also, instead of:

Code: Select all

if {[regexp -- {^#} $text]} { 
you should use:

Code: Select all

if {[string equal -length 1 # $channel]} {
The chanlist function returns a list of nicks in one channel including bot's nick thus the check:

Code: Select all

if {[set bot [lsearch $nicklist $botnick]] != -1}
always returns true, so skip ahead and remove him from the list.
Once the game is over, the king and the pawn go back in the same box.
Post Reply