You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature request:
To introduce a decorator @allowed_channels that takes a list of white-listed channels, similarly to the @allowed_users decorator.
Something similar to the following pseudocode:
def allowed_channels(*channels):
"""Decorator that limits the bot to the specified list of channels."""
def plugin(func):
def wrapper(message, *args, **kw):
is_direct_message = message.is_direct_message()
is_in_allowed_channel = message.get_channel_name() in channels
if not is_direct_message and not is_in_allowed_channel:
return message.reply(f'This bot can only be used inside the following channel(s): {", ".join(channels)}.')
return func(message, *args, **kw)
return wrapper
return plugin
The text was updated successfully, but these errors were encountered:
ghbacct
changed the title
Feature request: @allowed_channels decorator similar to @allowed_users
Feature request: @allowed_channels decorator similar to @allowed_users
Dec 27, 2018
As per enhancement request #88 I am adding the ability to limit
bot plugin functions so specific channels. You can use either the
channel display name or the url name.
* Adding new decorator allowed_channels
As per enhancement request #88 I am adding the ability to limit
bot plugin functions so specific channels. You can use either the
channel display name or the url name.
* Doing some flake8 cleanup
* Reducing complexity score flagged by codeclimate
There's one issue however: using@allowed_channelsprevents the plugin from being used in DMs.
Is that intentional? Seems to me like an edge case that just slipped by.
Yes edge case indeed. DMs are uniquely named channels. Depending on how we want this enhancement to work, we can update the code to allow the plugin to work in DMs regardless of allowed_channels(), either way we should document the intent.
Feature request:
To introduce a decorator
@allowed_channels
that takes a list of white-listed channels, similarly to the@allowed_users
decorator.Something similar to the following pseudocode:
The text was updated successfully, but these errors were encountered: