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.

show whos active

Old posts that have not been replied to for several years.
Locked
k
kanibus
Halfop
Posts: 44
Joined: Tue May 03, 2005 7:22 am

show whos active

Post by kanibus »

hey im trying to write a script for my team thats pretty simple. it just has to add you to a list if you say !on remove you if you say !off and list all active if you say !liston. this should be for channel operators only. here is what i have so far:

Code: Select all

bind pubm O|F * triggers

global whoson
set whoson [list "no one"]

proc triggers {nick uhost hand chan arg} {
    set trigger [lindex [split $arg] 0]

    switch -exact -- [string tolower $trigger] {
        "!on" {
           if {lindex [$whoson 0] == "no one"} {
           set whoson [list $nick]
           putquick "NOTICE $nick :You've been added to the 'on-line' list, noone else is on at the moment though."
       } else {
           set whoson [linsert $whoson end $nick]
           putquick "NOTICE $nick :You've been added to the 'on-line' list."
         }
        }
        "!off" {
            if { [lsearch -exact $whoson $nick ] >-1 } {
            set playerindex [lsearch -exact $whoson $nick]
            set whoson [lreplace $whoson $playerindex ""]
            putquick "NOTICE $nick :You've been removed to the 'on-line' list. later!"
         }
        }
        "!liston" {
            set x 0
            set listlong [llength $whoson]
            putquick "NOTICE $nick :/0030,1d/0037,1D/0030,1ect members online:"
            while {$x<$listlong} {
            putquick "NOTICE $nick :[lindex $x]"
            incr x
      }
    }
  }
}
but it doesnt work, and i get no tcl errors
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

bind pubm - * triggers 

proc triggers {nick uhost hand chan arg} { 
 global whoson
 if {![isop $nick $chan]} {return 0}
 set trigger [lindex [split $arg] 0] 
 if {![info exists whoson]} {set whoson [list]}
 switch -exact -- [string tolower $trigger] { 
  "!on" { 
   if {[lsearch -exact $whoson $nick] == -1} {
    lappend whoson $nick 
    putquick "NOTICE $nick :You've been added to the 'on-line' list."
   } {
    putquick "NOTICE $nick :You already are on my 'on-line' list."
   }
  } 
  "!off" { 
   if {[set nickindex [lsearch -exact $whoson $nick]] != -1} { 
    set whoson [lreplace $whoson $nickindex $nickindex] 
    putquick "NOTICE $nick :You've been removed to the 'on-line' list. later!" 
   } {
    putquick "NOTICE $nick :You're not on my 'on-line' list."
   }
  } 
  "!liston" { 
   if {[llength $whoson] != 0} {
    putquick "NOTICE $nick :/0030,1d/0037,1D/0030,1ect members online:" 
    foreach online $whoson { 
     putquick "NOTICE $nick :$online" 
    }
   } {
    putquick "NOTICE $nick :There are no users oline."
   } 
  } 
 } 
}
I assume you meant channel operaters, so I removed the O|F bind flags and added a check to see if nick is oped.
k
kanibus
Halfop
Posts: 44
Joined: Tue May 03, 2005 7:22 am

Post by kanibus »

thanks sir_fz, you never cease to amaze me :)
k
kanibus
Halfop
Posts: 44
Joined: Tue May 03, 2005 7:22 am

Post by kanibus »

so now if i were to write binds to remove on quit and part how could i make the list global so that i can use it in other processes. i tried naming it ::whoson and global ::whoson but its still not grabbing the list.
now im not sure if this is going to slow the bot down a lot by checking on every part and quit so any advice is more than welcomed, thanks again in advance :) here is what i had written

Code: Select all

bind part - * leave
bind sign - * signoff

proc leave {nick uhost hand chan {reason ""}} {
 global ::whoson
  if {[set nickindex [lsearch -exact $::whoson $nick]] != -1} {
   set ::whoson [lreplace $::whoson $nickindex $nickindex]
  }
}


proc signoff {nick uhost hand chan reason} {
global ::whoson
  if {[set nickindex [lsearch -exact $::whoson $nick]] != -1} {
   set ::whoson [lreplace $::whoson $nickindex $nickindex]
  }
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

if you add

Code: Select all

global whoson
to the proc then you can use $whoson in the proc since it became a global variable. while if you don't add the global line, you can use $::whoson or ::whoson for set...etc
Locked