0
# Channel Management
1
2
Comprehensive channel lifecycle management for public Rocket.Chat channels. Provides complete functionality for creating, configuring, administering, and managing channel membership, permissions, and content.
3
4
## Capabilities
5
6
### Channel Creation and Information
7
8
Create new public channels and retrieve channel information and metadata.
9
10
```python { .api }
11
def channels_create(self, name, **kwargs):
12
"""
13
Create a new public channel.
14
15
Parameters:
16
- name (str): Channel name (required)
17
- members (list, optional): List of usernames to add as members
18
- readonly (bool, optional): Create as read-only channel
19
- customFields (dict, optional): Custom fields for the channel
20
21
Returns:
22
requests.Response: Channel creation result
23
"""
24
25
def channels_info(self, room_id=None, channel=None, **kwargs):
26
"""
27
Get channel information.
28
29
Parameters:
30
- room_id (str, optional): Channel ID
31
- channel (str, optional): Channel name
32
33
Returns:
34
requests.Response: Channel information
35
"""
36
37
def channels_delete(self, room_id=None, channel=None, **kwargs):
38
"""
39
Delete a public channel.
40
41
Parameters:
42
- room_id (str, optional): Channel ID
43
- channel (str, optional): Channel name
44
45
Returns:
46
requests.Response: Deletion result
47
"""
48
```
49
50
### Channel Listing and Discovery
51
52
List and discover channels based on user access and criteria.
53
54
```python { .api }
55
def channels_list(self, **kwargs):
56
"""
57
List all channels the user has access to.
58
59
Parameters:
60
- offset (int, optional): Number of items to skip
61
- count (int, optional): Number of items to return
62
- sort (dict, optional): Sort criteria
63
- query (dict, optional): Search query
64
65
Returns:
66
requests.Response: List of channels
67
"""
68
69
def channels_list_joined(self, **kwargs):
70
"""
71
List channels the user has joined.
72
73
Parameters:
74
- offset (int, optional): Number of items to skip
75
- count (int, optional): Number of items to return
76
77
Returns:
78
requests.Response: List of joined channels
79
"""
80
81
def channels_online(self, _id=None, query=None):
82
"""
83
List online users in channels.
84
85
Parameters:
86
- _id (str, optional): Channel ID
87
- query (dict, optional): Query parameters
88
89
Returns:
90
requests.Response: Online users information
91
"""
92
```
93
94
### Membership Management
95
96
Manage channel membership including invitations, removals, and access control.
97
98
```python { .api }
99
def channels_invite(self, room_id, user_id, **kwargs):
100
"""
101
Invite a user to the channel.
102
103
Parameters:
104
- room_id (str): Channel ID
105
- user_id (str): User ID to invite
106
107
Returns:
108
requests.Response: Invitation result
109
"""
110
111
def channels_kick(self, room_id, user_id, **kwargs):
112
"""
113
Remove a user from the channel.
114
115
Parameters:
116
- room_id (str): Channel ID
117
- user_id (str): User ID to remove
118
119
Returns:
120
requests.Response: Removal result
121
"""
122
123
def channels_join(self, room_id, join_code, **kwargs):
124
"""
125
Join a channel.
126
127
Parameters:
128
- room_id (str): Channel ID
129
- join_code (str): Join code if required
130
131
Returns:
132
requests.Response: Join result
133
"""
134
135
def channels_leave(self, room_id, **kwargs):
136
"""
137
Leave a channel.
138
139
Parameters:
140
- room_id (str): Channel ID
141
142
Returns:
143
requests.Response: Leave result
144
"""
145
146
def channels_members(self, room_id=None, channel=None, **kwargs):
147
"""
148
List channel members.
149
150
Parameters:
151
- room_id (str, optional): Channel ID
152
- channel (str, optional): Channel name
153
- offset (int, optional): Number of items to skip
154
- count (int, optional): Number of items to return
155
156
Returns:
157
requests.Response: List of members
158
"""
159
```
160
161
### Channel Configuration
162
163
Configure channel settings including name, description, topic, and behavior.
164
165
```python { .api }
166
def channels_rename(self, room_id, name, **kwargs):
167
"""
168
Rename a channel.
169
170
Parameters:
171
- room_id (str): Channel ID
172
- name (str): New channel name
173
174
Returns:
175
requests.Response: Rename result
176
"""
177
178
def channels_set_description(self, room_id, description, **kwargs):
179
"""
180
Set channel description.
181
182
Parameters:
183
- room_id (str): Channel ID
184
- description (str): Channel description
185
186
Returns:
187
requests.Response: Update result
188
"""
189
190
def channels_set_topic(self, room_id, topic, **kwargs):
191
"""
192
Set channel topic.
193
194
Parameters:
195
- room_id (str): Channel ID
196
- topic (str): Channel topic
197
198
Returns:
199
requests.Response: Update result
200
"""
201
202
def channels_set_announcement(self, room_id, announcement, **kwargs):
203
"""
204
Set channel announcement.
205
206
Parameters:
207
- room_id (str): Channel ID
208
- announcement (str): Channel announcement
209
210
Returns:
211
requests.Response: Update result
212
"""
213
214
def channels_set_read_only(self, room_id, read_only, **kwargs):
215
"""
216
Set channel read-only status.
217
218
Parameters:
219
- room_id (str): Channel ID
220
- read_only (bool): Read-only status
221
222
Returns:
223
requests.Response: Update result
224
"""
225
226
def channels_set_type(self, room_id, a_type, **kwargs):
227
"""
228
Set channel type.
229
230
Parameters:
231
- room_id (str): Channel ID
232
- a_type (str): Channel type ('c' for channel, 'p' for private)
233
234
Returns:
235
requests.Response: Update result
236
"""
237
238
def channels_set_custom_fields(self, rid, custom_fields):
239
"""
240
Set custom fields for channel.
241
242
Parameters:
243
- rid (str): Channel ID
244
- custom_fields (dict): Custom fields dictionary
245
246
Returns:
247
requests.Response: Update result
248
"""
249
```
250
251
### Channel Administration
252
253
Administrative functions for channel management including archiving, defaults, and access control.
254
255
```python { .api }
256
def channels_archive(self, room_id, **kwargs):
257
"""
258
Archive a channel.
259
260
Parameters:
261
- room_id (str): Channel ID
262
263
Returns:
264
requests.Response: Archive result
265
"""
266
267
def channels_unarchive(self, room_id, **kwargs):
268
"""
269
Unarchive a channel.
270
271
Parameters:
272
- room_id (str): Channel ID
273
274
Returns:
275
requests.Response: Unarchive result
276
"""
277
278
def channels_set_default(self, room_id, default, **kwargs):
279
"""
280
Set channel as default.
281
282
Parameters:
283
- room_id (str): Channel ID
284
- default (bool): Default channel status
285
286
Returns:
287
requests.Response: Update result
288
"""
289
290
def channels_set_join_code(self, room_id, join_code, **kwargs):
291
"""
292
Set join code for channel.
293
294
Parameters:
295
- room_id (str): Channel ID
296
- join_code (str): Join code required to join channel
297
298
Returns:
299
requests.Response: Update result
300
"""
301
302
def channels_close(self, room_id, **kwargs):
303
"""
304
Close channel for user.
305
306
Parameters:
307
- room_id (str): Channel ID
308
309
Returns:
310
requests.Response: Close result
311
"""
312
313
def channels_open(self, room_id, **kwargs):
314
"""
315
Open channel for user.
316
317
Parameters:
318
- room_id (str): Channel ID
319
320
Returns:
321
requests.Response: Open result
322
"""
323
```
324
325
### Role Management
326
327
Manage user roles within channels including moderators, owners, and leaders.
328
329
```python { .api }
330
def channels_add_moderator(self, room_id, user_id, **kwargs):
331
"""
332
Add channel moderator.
333
334
Parameters:
335
- room_id (str): Channel ID
336
- user_id (str): User ID to make moderator
337
338
Returns:
339
requests.Response: Role assignment result
340
"""
341
342
def channels_remove_moderator(self, room_id, user_id, **kwargs):
343
"""
344
Remove channel moderator.
345
346
Parameters:
347
- room_id (str): Channel ID
348
- user_id (str): User ID to remove moderator role
349
350
Returns:
351
requests.Response: Role removal result
352
"""
353
354
def channels_moderators(self, room_id=None, channel=None, **kwargs):
355
"""
356
List channel moderators.
357
358
Parameters:
359
- room_id (str, optional): Channel ID
360
- channel (str, optional): Channel name
361
362
Returns:
363
requests.Response: List of moderators
364
"""
365
366
def channels_add_owner(self, room_id, user_id=None, username=None, **kwargs):
367
"""
368
Add channel owner.
369
370
Parameters:
371
- room_id (str): Channel ID
372
- user_id (str, optional): User ID
373
- username (str, optional): Username
374
375
Returns:
376
requests.Response: Role assignment result
377
"""
378
379
def channels_remove_owner(self, room_id, user_id, **kwargs):
380
"""
381
Remove channel owner.
382
383
Parameters:
384
- room_id (str): Channel ID
385
- user_id (str): User ID to remove owner role
386
387
Returns:
388
requests.Response: Role removal result
389
"""
390
391
def channels_add_leader(self, room_id, user_id, **kwargs):
392
"""
393
Add channel leader.
394
395
Parameters:
396
- room_id (str): Channel ID
397
- user_id (str): User ID to make leader
398
399
Returns:
400
requests.Response: Role assignment result
401
"""
402
403
def channels_remove_leader(self, room_id, user_id, **kwargs):
404
"""
405
Remove channel leader.
406
407
Parameters:
408
- room_id (str): Channel ID
409
- user_id (str): User ID to remove leader role
410
411
Returns:
412
requests.Response: Role removal result
413
"""
414
415
def channels_roles(self, room_id=None, room_name=None, **kwargs):
416
"""
417
List user roles in channel.
418
419
Parameters:
420
- room_id (str, optional): Channel ID
421
- room_name (str, optional): Channel name
422
423
Returns:
424
requests.Response: List of user roles
425
"""
426
```
427
428
### Content and History
429
430
Access channel content including message history, files, and statistics.
431
432
```python { .api }
433
def channels_history(self, room_id, **kwargs):
434
"""
435
Get channel message history.
436
437
Parameters:
438
- room_id (str): Channel ID
439
- latest (str, optional): Latest message timestamp
440
- oldest (str, optional): Oldest message timestamp
441
- inclusive (bool, optional): Include boundaries
442
- count (int, optional): Number of messages
443
- unreads (bool, optional): Include unread count
444
445
Returns:
446
requests.Response: Message history
447
"""
448
449
def channels_files(self, room_id=None, room_name=None, **kwargs):
450
"""
451
List files in channel.
452
453
Parameters:
454
- room_id (str, optional): Channel ID
455
- room_name (str, optional): Channel name
456
- offset (int, optional): Number of items to skip
457
- count (int, optional): Number of items to return
458
459
Returns:
460
requests.Response: List of files
461
"""
462
463
def channels_counters(self, room_id=None, room_name=None, **kwargs):
464
"""
465
Get channel counters.
466
467
Parameters:
468
- room_id (str, optional): Channel ID
469
- room_name (str, optional): Channel name
470
471
Returns:
472
requests.Response: Channel statistics
473
"""
474
475
def channels_get_all_user_mentions_by_channel(self, room_id, **kwargs):
476
"""
477
Get all user mentions in channel.
478
479
Parameters:
480
- room_id (str): Channel ID
481
- offset (int, optional): Number of items to skip
482
- count (int, optional): Number of items to return
483
484
Returns:
485
requests.Response: List of mentions
486
"""
487
```
488
489
### Integration Management
490
491
Manage channel integrations and webhooks.
492
493
```python { .api }
494
def channels_get_integrations(self, room_id, **kwargs):
495
"""
496
Get channel integrations.
497
498
Parameters:
499
- room_id (str): Channel ID
500
- offset (int, optional): Number of items to skip
501
- count (int, optional): Number of items to return
502
503
Returns:
504
requests.Response: List of integrations
505
"""
506
507
def channels_add_all(self, room_id, **kwargs):
508
"""
509
Add all server users to channel.
510
511
Parameters:
512
- room_id (str): Channel ID
513
514
Returns:
515
requests.Response: Addition result
516
"""
517
```
518
519
## Usage Examples
520
521
### Creating and Configuring a Channel
522
523
```python
524
# Create a new channel
525
response = rocket.channels_create(
526
name='project-alpha',
527
members=['john.doe', 'jane.smith'],
528
readonly=False
529
)
530
channel_id = response.json()['channel']['_id']
531
532
# Configure the channel
533
rocket.channels_set_description(channel_id, 'Project Alpha discussion channel')
534
rocket.channels_set_topic(channel_id, 'Daily updates and collaboration')
535
rocket.channels_set_announcement(channel_id, 'Welcome to Project Alpha!')
536
537
# Add moderators
538
rocket.channels_add_moderator(channel_id, 'manager_user_id')
539
```
540
541
### Managing Channel Membership
542
543
```python
544
# Invite users to channel
545
rocket.channels_invite(channel_id, 'new_user_id')
546
547
# List current members
548
members = rocket.channels_members(room_id=channel_id, count=50)
549
print(f"Channel has {len(members.json()['members'])} members")
550
551
# Remove inactive user
552
rocket.channels_kick(channel_id, 'inactive_user_id')
553
```