Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #129 from d0iasm/fix/python_3
Browse files Browse the repository at this point in the history
Update example files from python 2 to python 3
  • Loading branch information
simonsolnes authored Mar 9, 2018
2 parents ca7f347 + b58e1f3 commit f1efe37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
14 changes: 7 additions & 7 deletions examples/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ def list_slack():
response = slack.channels.list()
channels = response.body['channels']
for channel in channels:
print channel['id'], channel['name']
print(channel['id'], channel['name'])
# if not channel['is_archived']:
# slack.channels.join(channel['name'])
print
print()

# Get users list
response = slack.users.list()
users = response.body['members']
for user in users:
if not user['deleted']:
print user['id'], user['name'], user['is_admin'], user[
'is_owner']
print
except KeyError, ex:
print 'Environment variable %s not set.' % str(ex)
print(user['id'], user['name'], user['is_admin'], user[
'is_owner'])
print()
except KeyError as ex:
print('Environment variable %s not set.' % str(ex))


if __name__ == '__main__':
Expand Down
15 changes: 5 additions & 10 deletions examples/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@ def post_slack():
token = os.environ['SLACK_TOKEN']
slack = Slacker(token)

obj = slack.chat.post_message(
channel='#general',
text='',
as_user=True,
attachments=[{"pretext": "Subject",
"text": "Body"}])
print obj.successful, obj.__dict__['body']['channel'], obj.__dict__[
'body']['ts']
except KeyError, ex:
print 'Environment variable %s not set.' % str(ex)
obj = slack.chat.post_message('#general', 'Hello fellow slackers!')
print(obj.successful, obj.__dict__['body']['channel'], obj.__dict__[
'body']['ts'])
except KeyError as ex:
print('Environment variable %s not set.' % str(ex))


if __name__ == '__main__':
Expand Down

0 comments on commit f1efe37

Please sign in to comment.