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.

Change key for several channels

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
G
Godzilla
Voice
Posts: 8
Joined: Sat Mar 25, 2006 12:05 pm

Change key for several channels

Post by Godzilla »

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
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

globalkey

Post by DragnLord »

Code: Select all

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.
G
Godzilla
Voice
Posts: 8
Joined: Sat Mar 25, 2006 12:05 pm

Post by Godzilla »

My mistake, i meant the channel password.

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

Thx in advance!
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

replace the procedure

Code: Select all

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}
   }
}
G
Godzilla
Voice
Posts: 8
Joined: Sat Mar 25, 2006 12:05 pm

Post by Godzilla »

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.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Code: Select all

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.
G
Godzilla
Voice
Posts: 8
Joined: Sat Mar 25, 2006 12:05 pm

Post by Godzilla »

Not at QuakeNet and i still have no ideas to solve this problem.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

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: Select all

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"
      }
   }
}
G
Godzilla
Voice
Posts: 8
Joined: Sat Mar 25, 2006 12:05 pm

Post by Godzilla »

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"?
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

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: Select all

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"
      }
   }
}
G
Godzilla
Voice
Posts: 8
Joined: Sat Mar 25, 2006 12:05 pm

Post by Godzilla »

works, big thx!
Post Reply