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.

aidle.tcl component

Old posts that have not been replied to for several years.
Locked
User avatar
FiRe
Voice
Posts: 18
Joined: Mon Jan 19, 2004 6:40 am

aidle.tcl component

Post by FiRe »

Currently it only does a message at a random time from 1 to $ai_time right?

How do I modify it so that it does message between two time periods? say $ai_timemin and $ai_timemax?

Code: Select all

# netbots.tcl v4.09 (1 April 2002)
# Copyright 1998-2002 by slennox
# slennox's eggdrop page - http://www.egghelp.org/

## aidle.tcl component script ##

proc ai_sendmsg {} {
  global ai_chans ai_msgbots ai_msgs ai_time ai_uidle botnick
  if {$ai_chans == ""} {
    set chan [lindex [channels] [rand [llength [channels]]]]
  } else {
    set chan [lindex $ai_chans [rand [llength $ai_chans]]]
  }
  if {$ai_msgbots} {
    if {[validchan $chan] && [botonchan $chan]} {
      set botlist ""
      foreach bot [chanlist $chan b] {
        if {$bot == $botnick || [onchansplit $bot $chan]} {continue}
        lappend botlist $bot
      }
      if {$botlist != ""} {
        puthelp "PRIVMSG [lindex $botlist [rand [llength $botlist]]] :[lindex $ai_msgs [rand [llength $ai_msgs]]]"
      }
    }
  } else {
    puthelp "PRIVMSG $chan :[lindex $ai_msgs [rand [llength $ai_msgs]]]"
  }
  if {$ai_uidle} {
    utimer [expr 140 + [rand 40]] ai_sendmsg
  } else {
    timer [expr [rand $ai_time] + 1] ai_sendmsg
  }
  return 0
}

set ai_chans [split $ai_chans]

if {$ai_uidle} {
  if {![string match *ai_sendmsg* [utimers]]} {
    utimer [expr 140 + [rand 40]] ai_sendmsg
  }
} else {
  if {![string match *ai_sendmsg* [timers]]} {
    timer [expr [rand $ai_time] + 1] ai_sendmsg
  }
}

return "nb_info 4.09.0"
User avatar
slennox
Owner
Posts: 593
Joined: Sat Sep 22, 2001 8:00 pm
Contact:

Post by slennox »

Quickest mod: find the two line that match

Code: Select all

timer [expr [rand $ai_time] + 1] ai_sendmsg
and replace them with

Code: Select all

timer [expr {[rand $ai_time] + $ai_timemin}] ai_sendmsg
Then add your "set ai_timemin" line, which will be the minimum interval. The maximum interval will be ai_time + ai_timemin. If you wanted between 20 and 60 minutes, for example, you would set ai_timemin to 20, and ai_time to 40. There is actually an error of 1 minute, but ignoring that saves some code :mrgreen:
Locked