-
Notifications
You must be signed in to change notification settings - Fork 59
/
Channel.php
233 lines (215 loc) · 6.74 KB
/
Channel.php
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?php
namespace Vluzrmos\SlackApi\Methods;
use Vluzrmos\SlackApi\Contracts\SlackChannel;
class Channel extends SlackMethod implements SlackChannel
{
protected $methodsGroup = 'conversations.';
/**
* This method archives a channel.
*
* @param string $channel Channel to archive
*
* @return array
*/
public function archive($channel)
{
return $this->method('archive', ['channel' => $channel]);
}
/**
* This method crate a channel with a given name.
*
* @param string $name Name of channel to create
*
* @return array
*/
public function create($name)
{
return $this->method('create', ['name' => $name]);
}
/**
* This method returns a portion of messages/events from the specified channel.
* To read the entire history for a channel, call the method with no `latest` or `oldest` arguments,
* and then continue paging using the instructions below.
* @see https://api.slack.com/methods/conversations.history
*
* @param string $channel Channel to fetch history for.
* @param int $limit Number of messages to return, between 1 and 1000.
* @param string $latest End of time range of messages to include in results.
* @param int $oldest Start of time range of messages to include in results.
* @param int $inclusive Include messages with latest or oldest timestamp in results.
*
* @return array
*/
public function history($channel, $limit = 100, $latest = null, $oldest = 0, $inclusive = 1)
{
return $this->method('history', compact('channel', 'limit', 'latest', 'oldest', 'inclusive'));
}
/**
* This method returns information about a team channel.
*
* @see https://api.slack.com/methods/conversations.info
*
* @param string $channel Channel to get info on
*
* @return array
*/
public function info($channel)
{
return $this->method('info', ['channel' => $channel]);
}
/**
* This method is used to invite a user to a channel. The calling user must be a member of the channel.
*
* @see https://api.slack.com/methods/conversations.invite
*
* @param string $channel
* @param string $user
*
* @return array
*/
public function invite($channel, $user)
{
return $this->method('invite', compact('channel', 'user'));
}
/**
* This method is used to join a channel. If the channel does not exist, it is created.
*
* @see https://api.slack.com/methods/conversations.join
*
* @param string $name Channel name to join in
*
* @return array
*/
public function join($name)
{
return $this->method('join', ['name' => $name]);
}
/**
* This method allows a user to remove another member from a team channel.
*
* @see https://api.slack.com/methods/conversations.kick
*
* @param string $channel
* @param string $user
*
* @return array
*/
public function kick($channel, $user)
{
return $this->method('kick', compact('channel', 'user'));
}
/**
* This method is used to leave a channel.
*
* @see https://api.slack.com/methods/conversations.leave
*
* @param string $channel
*
* @return array
*/
public function leave($channel)
{
return $this->method('leave', ['channel' => $channel]);
}
/**
* This method returns a list of all channels in the team. This includes channels the caller is in, channels they are not currently in, and archived conversations.
* The number of (non-deactivated) members in each channel is also returned.
*
* @see https://api.slack.com/methods/conversations.list
*
* @param int $exclude_archived Don't return archived conversations.
*
* @return array
*/
public function all($exclude_archived = 1)
{
return $this->method('list', compact('exclude_archived'));
}
/**
* This method returns a list of all channels in the team. This includes channels the caller is in, channels they are not currently in, and archived conversations.
* The number of (non-deactivated) members in each channel is also returned.
*
* @see https://api.slack.com/methods/conversations.list
*
* @param int $exclude_archived Don't return archived conversations.
*
* @return array
*/
public function lists($exclude_archived = 1)
{
return $this->all($exclude_archived);
}
/**
* This method moves the read cursor in a channel.
*
* @see https://api.slack.com/methods/conversations.mark
*
* @param string $channel Channel to set reading cursor in.
* @param string|int $ts Timestamp of the most recently seen message.
*
* @return array
*/
public function mark($channel, $ts)
{
return $this->method('mark', compact($channel, $ts));
}
/**
* This method renames a team channel.
*
* The only people who can rename a channel are team admins, or the person that originally
* created the channel. Others will recieve a "not_authorized" error.
*
* @see https://api.slack.com/methods/conversations.rename
*
* @param string $channel Channel to rename
*
* @param string $name New name for channel
*
* @return array
*/
public function rename($channel, $name)
{
return $this->method('rename', compact($channel, $name));
}
/**
* This method is used to change the purpose of a channel. The calling user must be a member of the channel.
*
* @see https://api.slack.com/methods/conversations.setPurpose
*
* @param string $channel Channel to set the purpose of
* @param string $purpose The new purpose
*
* @return array
*/
public function setPurpose($channel, $purpose)
{
return $this->method('setPurpose', compact($channel, $purpose));
}
/**
* This method is used to change the topic of a channel. The calling user must be a member of the channel.
*
* @see https://api.slack.com/methods/conversations.setTopic
*
* @param string $channel
* @param string $topic
*
* @return array
*/
public function setTopic($channel, $topic)
{
return $this->method('setPurpose', compact($channel, $topic));
}
/**
* This method unarchives a channel. The calling user is added to the channel.
*
* @see https://api.slack.com/methods/conversations.unarchive
*
* @param string $channel Channel to unarchive
*
* @return array
*/
public function unarchive($channel)
{
return $this->method('unarchive', compact($channel));
}
}