egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

auto nick change

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Evilish
Voice


Joined: 07 May 2011
Posts: 5

PostPosted: Wed Feb 27, 2013 2:45 pm    Post subject: auto nick change Reply with quote

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
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Wed Feb 27, 2013 6:10 pm    Post subject: Reply with quote

Try this

Code:

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
      }
   }
}

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Evilish
Voice


Joined: 07 May 2011
Posts: 5

PostPosted: Sun Mar 03, 2013 7:19 am    Post subject: Reply with quote

thnx
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon Mar 11, 2013 9:08 pm    Post subject: Reply with quote

Madalin wrote:
Code:

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 [list] instead of hand-constructing your list will eliminate empty "" sets in your list. Smile

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:
# 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"
}

_________________
speechles' eggdrop tcl archive


Last edited by speechles on Tue Mar 12, 2013 2:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
dirty
Halfop


Joined: 08 Feb 2013
Posts: 40
Location: Romania

PostPosted: Tue Mar 12, 2013 5:29 am    Post subject: Reply with quote

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:
bind cron - "*/15 * * * *" change:nick

_________________
come to the dark side.. I have cookies!
WwW.BotZone.TK
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Tue Mar 12, 2013 1:25 pm    Post subject: Reply with quote

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:
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. Razz
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Wed Mar 13, 2013 1:12 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber