Skip to content

Commit ad9a380

Browse files
Update bolt.py
1 parent 7a16a8b commit ad9a380

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

0.1 SlackBot/bolt.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,25 @@ def conversation_info(client,message):
8282
print(client)
8383
print(message)
8484

85+
86+
87+
#find all channels of a user. How do we find user id? - user sends a message and we hold the user id using the message payload.
88+
89+
@app.message('allchannels')
90+
def find_all_channels(client,message):
91+
user_id = message['user']
92+
headers ={'Authorization':'Bearer xoxp-3657324970245-3645627919751-3685545535376-f19195d2433c6379ae66cbbdfdf925e2'}
93+
params = {'user':user_id}
94+
data = requests.get(url='https://slack.com/api/users.conversations',headers=headers,params=params).json()
95+
channels = data['channels']
96+
channel_id = []
97+
channel_name = []
98+
for channel in channels :
99+
channel_id.append(channel['id'])
100+
channel_name.append(channel['name'])
101+
print(channel_id)
102+
print(channel_name)
85103

86104
# Start your app
87105
if __name__ == "__main__":
88-
SocketModeHandler(app,SLACK_APP_TOKEN).start()
106+
SocketModeHandler(app,SLACK_APP_TOKEN).start()

0 commit comments

Comments
 (0)