-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack.py
86 lines (56 loc) · 1.2 KB
/
slack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from slacker import Slacker
import pprint
pp = pprint.PrettyPrinter(indent=4)
slack = Slacker('ADD_SLACK_API_TOKEN')
###########
## USERS ##
###########
response = slack.users.list()
users = response.body['members']
#pp.pprint(users)
for user in users:
print user['real_name']
print user['name']
print user['id']
print "\n"
##############
## CHANNELS ##
##############
slack_channels = slack.channels.list()
channels = slack_channels.body['channels']
# pp.pprint(channels)
# print "\n"
for c in channels:
print c['name']
print c['num_members']
print c['members']
print c['id']
print '\n'
##############
## HISTORY ###
##############
#This part is for history
# slack_history = slack.channels.history('ADD_SLACK_CHANNEL_ID',count=1000)
# history = slack_history.body
# pp.pprint(history)
# has_more = history['has_more']
# print 'has_more',has_more
# messages = history['messages']
# for m in messages:
# # pp.pprint(m)
# # print "\n"
# print m['text']
# try:
# print m['user']
# except:
# pass
# try:
# print m['reactions']
# except:
# pass
# try:
# print m['file']['reactions']
# print m['file']['initial_comment']['reactions']
# except:
# pass
# print "\n"