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 

Change key for several channels

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


Joined: 25 Mar 2006
Posts: 8

PostPosted: Sat Apr 15, 2006 1:19 pm    Post subject: Change key for several channels Reply with quote

Hi all,

i need a script to change the channel key at the same time in all channels (channels set in the script) and update the chanfile.


Variables:
keychannels: #chan #chan1 #chan2
masterchannel: #chanxy

Masterchannel: only in this channel can the command be executed
Keychannels: List of channels where the key will be changed on command

Command !globalkey xy

Can someone help me with this request?

Thanks in advance.

//Godzilla
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Sat Apr 15, 2006 3:03 pm    Post subject: globalkey Reply with quote

Code:
set keychannels "#chan1 #chan2"
set masterchannel "#chanxy"

bind pub m !globalkey keychan

proc keychan {n u h c t} {
   if {![string match -nocase $::masterchannel $c]} { return 0 }
   foreach i $::keychannels {
      if {[botisop $i]} {putserv "MODE $i :$t" -next}
   }
   savechannels
}

Tested, working.

Includes savechannels (as asked for), however changing the channel record wasn't asked for.
Back to top
View user's profile Send private message
Godzilla
Voice


Joined: 25 Mar 2006
Posts: 8

PostPosted: Mon Apr 17, 2006 11:20 am    Post subject: Reply with quote

My mistake, i meant the channel password.

On !globalkey newpw, the bot should set the "newpw" on all keychannels.

Thx in advance!
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Mon Apr 17, 2006 1:17 pm    Post subject: Reply with quote

replace the procedure
Code:
proc keychan {n u h c t} {
   if {![string match -nocase $::masterchannel $c]} { return 0 }
   foreach i $::keychannels {
      if {[botisop $i]} {putserv "MODE $i +k $t" -next}
   }
}
Back to top
View user's profile Send private message
Godzilla
Voice


Joined: 25 Mar 2006
Posts: 8

PostPosted: Mon Apr 17, 2006 1:22 pm    Post subject: Reply with quote

don't work, any mistake in the code?

Edit: Error Found: If there is any channel key set, the bot don't change it. If there is no key, it works.
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Mon Apr 17, 2006 4:17 pm    Post subject: Reply with quote

Code:
proc keychan {n u h c t} {
   if {![string match -nocase $::masterchannel $c]} { return 0 }
   foreach i $::keychannels {
      if {[botisop $i]} {
         putserv "MODE $i +k $t"
      }
   }
}

Works whether a key is set or not.
Back to top
View user's profile Send private message
Godzilla
Voice


Joined: 25 Mar 2006
Posts: 8

PostPosted: Tue Apr 18, 2006 12:24 pm    Post subject: Reply with quote

Not at QuakeNet and i still have no ideas to solve this problem.
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Tue Apr 18, 2006 12:35 pm    Post subject: Reply with quote

Godzilla wrote:
Not at QuakeNet and i still have no ideas to solve this problem.

Try putting in some putlogs to see what goes on, such as:
Code:

proc keychan {n u h c t} {
   putlog "recieved command from $n on $c"
   if {![string match -nocase $::masterchannel $c]} {
       putlog "channel does not match $::masterchannel"
       return 0
   }
   foreach i $::keychannels {
      if {[botisop $i]} {
         putlog "changing key in $c to $t"
         putserv "MODE $i +k $t"
      }
   }
}
Back to top
View user's profile Send private message
Godzilla
Voice


Joined: 25 Mar 2006
Posts: 8

PostPosted: Tue Apr 18, 2006 1:42 pm    Post subject: Reply with quote

The problem is, that you can not change the key if you don't remove it first. And to remove it, you must know the current key, because "mode #chan -k" dont work. Is it possible, that the script check which key is actually set an remove it first with mode "#chan -k key"?
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Tue Apr 18, 2006 2:21 pm    Post subject: Reply with quote

Godzilla wrote:
The problem is, that you can not change the key if you don't remove it first. And to remove it, you must know the current key, because "mode #chan -k" dont work. Is it possible, that the script check which key is actually set an remove it first with mode "#chan -k key"?

This should work for that network:
Code:

proc keychan {n u h c t} {
   if {![string match -nocase $::masterchannel $c]} {
       return 0
   }
   foreach i $::keychannels {
      if {[botisop $i]} {
         set oldkey [lindex [split [getchanmode $chan]] 1]
         putserv "MODE $i -k $oldkey"
         putserv "MODE $i +k $t"
      }
   }
}
Back to top
View user's profile Send private message
Godzilla
Voice


Joined: 25 Mar 2006
Posts: 8

PostPosted: Wed Apr 19, 2006 11:40 am    Post subject: Reply with quote

works, big thx!
Back to top
View user's profile Send private message
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