| View previous topic :: View next topic |
| Author |
Message |
Godzilla Voice
Joined: 25 Mar 2006 Posts: 8
|
Posted: Sat Apr 15, 2006 1:19 pm Post subject: Change key for several channels |
|
|
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 |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Sat Apr 15, 2006 3:03 pm Post subject: globalkey |
|
|
| 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 |
|
 |
Godzilla Voice
Joined: 25 Mar 2006 Posts: 8
|
Posted: Mon Apr 17, 2006 11:20 am Post subject: |
|
|
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 |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Mon Apr 17, 2006 1:17 pm Post subject: |
|
|
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 |
|
 |
Godzilla Voice
Joined: 25 Mar 2006 Posts: 8
|
Posted: Mon Apr 17, 2006 1:22 pm Post subject: |
|
|
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 |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Mon Apr 17, 2006 4:17 pm Post subject: |
|
|
| 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 |
|
 |
Godzilla Voice
Joined: 25 Mar 2006 Posts: 8
|
Posted: Tue Apr 18, 2006 12:24 pm Post subject: |
|
|
| Not at QuakeNet and i still have no ideas to solve this problem. |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Tue Apr 18, 2006 12:35 pm Post subject: |
|
|
| 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 |
|
 |
Godzilla Voice
Joined: 25 Mar 2006 Posts: 8
|
Posted: Tue Apr 18, 2006 1:42 pm Post subject: |
|
|
| 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 |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Tue Apr 18, 2006 2:21 pm Post subject: |
|
|
| 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 |
|
 |
Godzilla Voice
Joined: 25 Mar 2006 Posts: 8
|
Posted: Wed Apr 19, 2006 11:40 am Post subject: |
|
|
| works, big thx! |
|
| Back to top |
|
 |
|