rollcall tcl for the channel

Active 3 Replies 67 Views 2022-12-21 07:19:57 TCL Support
Hi Sir, can you help me how to fixed this error. kudos Sir!

proc roll_call {nick uhost handle chan text} {
  global botnick
  # Get a list of all users in the channel
  set users [channel get [channel name]]
  # Initialize counters for active and inactive users
  set active 0
  set inactive 0
  # Iterate through the list of users and display their nicknames in random colors
  # if they have been active within the past 5 minutes and are not the bot
  putquick "Users present for the past 5 minutes: "
  foreach user $users {
    set idle [lindex [user get $user idle] 0]
    if {$idle < 300 && [user get $user nick] != [botnick]} {
      # Generate a random color for the nickname
      set r [expr {int(rand()*255)}]
      set g [expr {int(rand()*255)}]
      set b [expr {int(rand()*255)}]
      putquick [format "\cC%02x%02x%02x%s " $r $g $b [user get $user nick]]
      incr active
    } else {
      incr inactive
    }
  }
  # Display the total number of users in the channel
  putquick "
Total users: [llength $users]
"
  # Display the number of active and inactive users
  putquick "Active users: $active
"
  putquick "Inactive users: $inactive
"
}
# Bind the roll_call proc to a trigger
bind pub -|- "!rollcall" roll_call
BLaCkShaDoW replied
1 Month
proc roll_call {nick uhost handle chan text} {
  global botnick
  # Get a list of all users in the channel
  set users [chanlist $chan]
  # Initialize counters for active and inactive users
  set active 0
  set inactive 0
  set userlist ""
  # Iterate through the list of users and display their nicknames in random colors
  # if they have been active within the past 5 minutes and are not the bot
  putquick "PRIVMSG $chan :Users present for the past 5 minutes: "
  foreach user $users {
    set idle [getchanidle $user $chan]
    if {$idle < 300 && $user != $botnick} {
  # Generating a random color code
      set rand_color [roll_call_color]
      lappend userlist "${rand_color}$user\003"
      incr active
    } else {
      incr inactive
    }
  }
  putquick "PRIVMSG $chan :[join [split $userlist] ", "]"
  # Display the total number of users in the channel
  putquick "PRIVMSG $chan :Total users: [llength $users]"
  # Display the number of active and inactive users
  putquick "PRIVMSG $chan :Active users: $active"
  putquick "PRIVMSG $chan :Inactive users: $inactive"
}
# Bind the roll_call proc to a trigger
bind pub -|- "!rollcall" roll_call


proc roll_call_color {} {
  set colors {
"\00300"
"\00301"   
"\00302" 
"\00303"   
"\00304"
"\00305"
"\00306"
"\00307"
"\00308"
"\00309"
"\00310"
"\00311"
"\00312"
"\00313"
"\00314"
"\00315"
  }
  return [lindex $colors [rand [llength $colors]]]
}

ventura.kevin52844 replied
1 Month
Thanks Sir! Working now... but instead to display to vertical... can you make it to display to horizontal?
Like:
Nick1 Nick2 Nick3 Nick4 ... and so on
Thanks again Sir!
Kudos!
BLaCkShaDoW replied
1 Month
try it.

proc roll_call {nick uhost handle chan text} {
  global botnick
  # Get a list of all users in the channel
  set users [chanlist $chan]
  # Initialize counters for active and inactive users
  set active 0
  set inactive 0
  # Iterate through the list of users and display their nicknames in random colors
  # if they have been active within the past 5 minutes and are not the bot
  putquick "Users present for the past 5 minutes: "
  foreach user $users {
    set idle [getchanidle $user $chan]
    if {$idle < 300 && $user != $botnick} {
  # Generating a random color code
      set rand_color [roll_call_color]
      putquick "PRIVMSG $chan :${rand_color}$user\003"
      incr active
    } else {
      incr inactive
    }
  }
  # Display the total number of users in the channel
  putquick "PRIVMSG $chan :Total users: [llength $users]"
  # Display the number of active and inactive users
  putquick "PRIVMSG $chan :Active users: $active"
  putquick "PRIVMSG $chan :Inactive users: $inactive"
}
# Bind the roll_call proc to a trigger
bind pub -|- "!rollcall" roll_call


proc roll_call_color {} {
  set colors {
"\00300"
"\00301"   
"\00302" 
"\00303"   
"\00304"
"\00305"
"\00306"
"\00307"
"\00308"
"\00309"
"\00310"
"\00311"
"\00312"
"\00313"
"\00314"
"\00315"
  }
  return [lindex $colors [rand [llength $colors]]]
}

loading...