File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,25 @@ def conversation_info(client,message):
82
82
print (client )
83
83
print (message )
84
84
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 )
85
103
86
104
# Start your app
87
105
if __name__ == "__main__" :
88
- SocketModeHandler (app ,SLACK_APP_TOKEN ).start ()
106
+ SocketModeHandler (app ,SLACK_APP_TOKEN ).start ()
You can’t perform that action at this time.
0 commit comments