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.

auto nick change

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
E
Evilish
Voice
Posts: 5
Joined: Sat May 07, 2011 2:20 pm

auto nick change

Post by Evilish »

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
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

Try this

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
		}
	}
}
E
Evilish
Voice
Posts: 5
Joined: Sat May 07, 2011 2:20 pm

Post by Evilish »

thnx
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Madalin 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
		}
	}
}
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. Using
  • instead of hand-constructing your list will eliminate empty "" sets in your list. :)

    I've adapted your code and gave it the ability to cycle through nicknames as well as randomly choose one. Comments so hopefully its clear what everything is doing. Changed the global varname from (temp) which is rather generic to a more unique (_nicks) as well. Other changes should be identifiable without noting.

    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"
    }
    
Last edited by speechles on Tue Mar 12, 2013 2:04 pm, edited 1 time in total.
d
dirty
Halfop
Posts: 40
Joined: Fri Feb 08, 2013 2:33 pm
Location: Romania
Contact:

Post by dirty »

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
come to the dark side.. I have cookies!
WwW.BotZone.TK
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

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
Seriously?

You don't know why??! It's clearly obvious what I've done there. Let me simplify it into the simplest terms. The most elegant example of consumerism. To the rookie eye they see problems because they narrow their audience too often. I on the other hand, expand my audience. You see dirty, tcl8.5 includes cron. tcl8.4 does not. The issue is, to perfect a concept you need an audience. Execution of the concept into a product needs to be worthwhile. For it to be worthwhile you need as large an audience as possible. The product in this case, is that snippet of code above. The audience is everyone using eggdrop. Without cron used, it expands the audience of eggdrop users to its full potential (EVERYONE CAN USE IT NOW). Adding cron, I've now crippled the product. Flawed it's execution. I've limited the audience.. You get it?! No?!

I've simply made a business decision here. That's all. A smart one at that. :P
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

lulz pwnt
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.
Post Reply