can someone make a script that will make the bot change his nick after X time ?
X may be in days
nicks r defined by me
thnx
Code: Select all
bind time - "00 * * * *" change:nick
set temp(nick) {
"nick111"
"nick222"
}
proc change:nick {min hour day month year} {
global temp
set randnick [lindex $temp(nick) [rand [llength $temp(nick))]]]
if {$randnick != ""} {
if {[string match -nocase $::botnick $randnick]} {
putserv "NICK [lindex $temp(nick) [rand [llength $temp(nick))]]]"
} else {
change:nick $min $hour $day $month $year
}
}
}
Not to nit pick at all. But I can help you here, figure out the problem you had. The problem is, if the list is "nick111" and "nick222" how then can we ever get "". It should never be "". But in your code, it was. Hence you have to check it isn't that. This is because of how you constructed your code. UsingMadalin wrote:Code: Select all
bind time - "00 * * * *" change:nick set temp(nick) { "nick111" "nick222" } proc change:nick {min hour day month year} { global temp set randnick [lindex $temp(nick) [rand [llength $temp(nick))]]] if {$randnick != ""} { if {[string match -nocase $::botnick $randnick]} { putserv "NICK [lindex $temp(nick) [rand [llength $temp(nick))]]]" } else { change:nick $min $hour $day $month $year } } }
Code: Select all
# put your time strings here when nicknames should be changed
# as it is below, it will issue a nick change every 15 minutes.
set _nicks(bindtime) [list 15* 30* 45* 00*]
# cycle through our binds to time
foreach b $_nicks(bindtime) {
bind time - $b change:nick
}
# using list here will eliminate possibility of
# having empty "" elelemts in the list.
# this should be a list of nicknames.
set _nicks(nicks) [list "nick111" "nick222"]
# cycle through the nicks or randomly choose
# 1 = cycle , 2 = random
set _nicks(type) 1
proc change:nick {min hour day month year} {
global _nicks
# to init loop pick must equal botnick
set pick $::botnick
# as long as pick is botnick, loop
while {[isbotnick $pick]} {
# cycle nicks means we count
if {$_nicks(type) < 2} {
# if counting var doesnt exist, init it
if {![info exists _nicks(count)]} { set _nicks(count) -1 }
# increment counter and check it isn't equal to length of list of nicks
# if it is set counter to zero
if {[incr _nicks(count)] == [llength $_nicks(nicks)]} { set _nicks(count) 0 }
# choose our pick based on counter position
set pick [lindex $_nicks(nicks) $_nicks(count)]
} else {
# randomly pick based on length of list of nicks
set pick [lindex $_nicks(nicks) [rand [llength $_nicks(nicks)]]]
}
}
# change nick
putserv "NICK $pick"
}
Code: Select all
bind cron - "*/15 * * * *" change:nick
Seriously?dirty wrote:why in the hell would you complicate the code that much and make a foreach to create bindings? just put a damn BIND CRON..
Code: Select all
bind cron - "*/15 * * * *" change:nick