Closed pauby closed 5 years ago
Hey @pauby That channel resolution error is probably the cause of this. Can you run this and let me know if all channels (public and private) are returned?
$getChannelParams = @{
Token = '<MY-TOKEN>'
ExcludeArchived = $true
Verbose = $false
Paging = $true
}
$allChannels = Get-SlackChannel @getChannelParams
Hey @devblackops, that code shows me all of the public channels with member count, topic and purpose populated. It shows me two private channels (the ones the bot has been invited to) with no member count, topic or purpose, just the channel name.
Is this maybe a limitation of poshbot to work with channel rules in private channels, Slack not providing the correct access to poshbot so it can resolve the private channel name and match it to the channel rule name? Do you know if anybody else using channel rules in private channels?
There was an issue with PSSlack retrieving info on private channels that was fixed in https://github.com/RamblingCookieMonster/PSSlack/pull/80 and https://github.com/RamblingCookieMonster/PSSlack/pull/90.
Because PoshBot wasn't resolving the private channel names/IDs, channels rules wasn't working.
To fix, I pinned the updated PSSlack version in PoshBot and implemented paging support for workspaces with a large number of channels in a62ef43ba859c59cd55a1c04e72758f2adc8e268.
Maybe there is another bug somewhere. I'll take a look!
Thanks @devblackops - Just in case I checked what version of PSSlack were installed and it's just 1.0.1 which is the latest.
As an update to this.
I moved PoshBot to it's own non-admin account (it was previously running under another non-admin account but wanted to isolate it). I ran the code from above and noticed that the channels PoshBot was invited to now had the purpose populated. There is nothing running in the other account that is not runnign here, it's on the same server, same installed modules etc.
I went ahead and run PoshBot and got a bit more info from the logs. It looked like it was failing because the version hadn't been specified.
I ended up with this config, which is now working:
ChannelRules = @(
@{
Channel = 'private-channel1'
IncludeCommands = @('*')
ExcludeCommands = @()
},
@{
Channel = 'private-channel2'
IncludeCommands = @(
'module:command1:*',
'module:command2:*',
'chocolatey.poshbot:sing:*',
'Builtin:Get-CommandHelp:*',
'Builtin:slap:*',
'Builtin:Get-ScheduledCommand:*',
'Builtin:New-ScheduledCommand:*',
'Builtin:Remove-ScheduledCommand:*'
)
ExcludeCommands = @()
}
)
Note the wildcard for the version.
I have found another bug (I think) which I'll raise an issue for though. This one, at the moment seems resoolved. If it crops up again I will re-open it.
When I leave the configuration with the default channel rules, everything works as expected. When I specify a channel rule, no commands can be accessed.
Expected Behavior
I expect the channel rules to apply to the channel names specified.
Current Behavior
When a specific channel rule is applied, it stop all commands working. The configuration I have is:
When I try and execute the
!man
command or!Get-CommandHelp
inprivate-channel2
I get the error:I have noticed this in the logs - no idea if it's relevant:
and then later:
Steps to Reproduce (for bugs)
Your Environment