Skip to content

Commit

Permalink
Fixed Channel Up/Down when No Token For Last Channel
Browse files Browse the repository at this point in the history
  • Loading branch information
talkkonnect committed Mar 5, 2022
1 parent b39a08b commit 55369e8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
27 changes: 19 additions & 8 deletions clientcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,15 @@ func (b *Talkkonnect) ChannelUp() {
b.Client.Self.Move(Channel)
}
} else {
for i := NextIndex + 1; i < len(b.Client.Channels); i++ {
log.Println("info: Skipping Channel")
Channel = b.Client.Channels.Find(ChannelsList[i].chanName)
for i := NextIndex + 1; i <= len(b.Client.Channels); i++ {
//special handling for when highest channel has no token
if i == len(b.Client.Channels) {
Channel = b.Client.Channels.Find()
b.Client.Self.Move(Channel)
return
} else {
Channel = b.Client.Channels.Find(ChannelsList[i].chanName)
}
if ChannelsList[i].chanenterPermissions {
b.Client.Self.Move(Channel)
break
Expand All @@ -415,23 +421,28 @@ func (b *Talkkonnect) ChannelDown() {
currentIndex := b.findChannelIndex(b.Client.Self.Channel.ID)
NextIndex := currentIndex

if currentIndex > 0 {
Channel = b.Client.Channels.Find(ChannelsList[currentIndex-1].chanName)
NextIndex = currentIndex - 1
if currentIndex == 0 {
//special handling of max channel without token
Channel = b.Client.Channels.Find(ChannelsList[len(b.Client.Channels)-1].chanName)
NextIndex = len(b.Client.Channels) - 1
}

if currentIndex == 1 {
Channel = b.Client.Channels.Find()
NextIndex = currentIndex - 1
}

if currentIndex > 1 {
Channel = b.Client.Channels.Find(ChannelsList[currentIndex-1].chanName)
NextIndex = currentIndex - 1
}

if ChannelsList[NextIndex].chanenterPermissions {
if Channel != nil {
b.Client.Self.Move(Channel)
}
} else {
for i := NextIndex - 1; i > 0; i-- {
log.Println("info: Skipping Channel")
for i := NextIndex - 1; i >= 0; i-- {
Channel = b.Client.Channels.Find(ChannelsList[i].chanName)
if ChannelsList[i].chanenterPermissions {
b.Client.Self.Move(Channel)
Expand Down
1 change: 1 addition & 0 deletions onevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func (b *Talkkonnect) OnPermissionDenied(e *gumble.PermissionDeniedEvent) {
log.Printf("warn: Permission Denied For Channel ID %v Channel Name %v\n", e.Channel.ID, e.Channel.Name)
for index, ch := range ChannelsList {
if ch.chanID == int(e.Channel.ID) {
log.Printf("warn: Setting Channel Index %v Channel ID %v Channel Name %v Channel Enter to False\n", index, e.Channel.ID, e.Channel.Name)
ChannelsList[index].chanenterPermissions = false
if ChannelAction == "channelup" {
b.ChannelUp()
Expand Down
4 changes: 2 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
package talkkonnect

const (
talkkonnectVersion string = "2.12.03"
talkkonnectVersion string = "2.12.04"
talkkonnectReleased string = "Mar 5 2022"
)

/* Release Notes
1. Fixed Channel Down Logic With Skipping Channels With No Permissions
1. Fixed Channel Up/Down when No Token For Last Channel
*/

0 comments on commit 55369e8

Please sign in to comment.