aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorBryan Mason <bmason@redhat.com>2023-07-30 10:16:43 -0700
committerGitHub <noreply@github.com>2023-07-30 19:16:43 +0200
commit7a27eff747db5275bd94517772294321540edbd9 (patch)
treef2a02007ebade083d830bd75cdc4869380fdbce8 /wee_slack.py
parent431bd3ce0b0dd43cd99579dccfd35f43b4e64fe4 (diff)
downloadwee-slack-7a27eff747db5275bd94517772294321540edbd9.tar.gz
feat: Filter channel list based on regular expression (#896)
It can be difficult to find a specific channel if there are thousands of them in your slack workspace. This enhancement allows you to filter the channels based on a regular expression.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py
index c87ea78..9b6193b 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -5626,14 +5626,16 @@ def command_teams(data, current_buffer, args):
@utf8_decode
def command_channels(data, current_buffer, args):
"""
- /slack channels
+ /slack channels [regex]
List the channels in the current team.
+ If regex is given show channels whose names match the regular expression.
"""
team = EVENTROUTER.weechat_controller.buffers[current_buffer].team
+ pat = re.compile(args)
channels = [
channel
for channel in team.channels.values()
- if channel.type not in ["im", "mpim"]
+ if channel.type not in ["im", "mpim"] and pat.search(channel.name)
]
def extra_info_function(channel):
@@ -5644,7 +5646,12 @@ def command_channels(data, current_buffer, args):
else:
return "not a member"
- return print_team_items_info(team, "Channels", channels, extra_info_function)
+ if args:
+ return print_team_items_info(
+ team, 'Channels that match "' + args + '"', channels, extra_info_function
+ )
+ else:
+ return print_team_items_info(team, "Channels", channels, extra_info_function)
@slack_buffer_required