Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update slack api endpoints to remove depreciated channels.* methods #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions slack_autoarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def slack_api_http(
def get_all_channels(self):
""" Get a list of all non-archived channels from slack channels.list. """
payload = {'exclude_archived': 1}
api_endpoint = 'channels.list'
api_endpoint = 'conversations.list'
channels = self.slack_api_http(api_endpoint=api_endpoint,
payload=payload)['channels']
all_channels = []
Expand Down Expand Up @@ -143,8 +143,8 @@ def get_last_message_timestamp(self, channel_history, too_old_datetime):
def is_channel_disused(self, channel, too_old_datetime):
""" Return True or False depending on if a channel is "active" or not. """
num_members = channel['num_members']
payload = {'inclusive': 0, 'oldest': 0, 'count': 50}
api_endpoint = 'channels.history'
payload = {'inclusive': 0, 'oldest': 0, 'limit': 50}
api_endpoint = 'conversations.history'

payload['channel'] = channel['id']
channel_history = self.slack_api_http(api_endpoint=api_endpoint,
Expand All @@ -165,7 +165,7 @@ def is_channel_whitelisted(self, channel, white_listed_channels):
# self.settings.get('skip_channel_str')
# if the channel purpose contains the string self.settings.get('skip_channel_str'), we'll skip it.
info_payload = {'channel': channel['id']}
channel_info = self.slack_api_http(api_endpoint='channels.info',
channel_info = self.slack_api_http(api_endpoint='conversations.info',
payload=info_payload,
method='GET')
channel_purpose = channel_info['channel']['purpose']['value']
Expand Down Expand Up @@ -197,7 +197,7 @@ def send_channel_message(self, channel_id, message):

def archive_channel(self, channel, alert):
""" Archive a channel, and send alert to slack admins. """
api_endpoint = 'channels.archive'
api_endpoint = 'conversations.archive'
stdout_message = 'Archiving channel... %s' % channel['name']
self.logger.info(stdout_message)

Expand Down