slack_autoarchive_10.py 626 B

123456789101112
  1. def archive_channel(self, channel, alert):
  2. """ Archive a channel, and send alert to slack admins. """
  3. api_endpoint = 'channels.archive'
  4. stdout_message = 'Archiving channel... %s' % channel['name']
  5. self.logger.info(stdout_message)
  6. if not self.settings.get('dry_run'):
  7. channel_message = alert.format(self.settings.get('days_inactive'))
  8. self.send_channel_message(channel['id'], channel_message)
  9. payload = {'channel': channel['id']}
  10. self.slack_api_http(api_endpoint=api_endpoint, payload=payload)
  11. self.logger.info(stdout_message)