@@ -110,7 +110,7 @@ defmodule ExIRC.Client do
110110 server :: binary ,
111111 port :: non_neg_integer ,
112112 options :: list ( ) | nil
113- ) :: :ok
113+ ) :: :ok | { :error , :timeout | :inet . posix ( ) }
114114 def connect! ( client , server , port , options \\ [ ] ) do
115115 GenServer . call ( client , { :connect , server , port , options , false } , :infinity )
116116 end
@@ -129,15 +129,15 @@ defmodule ExIRC.Client do
129129 server :: binary ,
130130 port :: non_neg_integer ,
131131 options :: list ( ) | nil
132- ) :: :ok
132+ ) :: :ok | { :error , any }
133133 def connect_ssl! ( client , server , port , options \\ [ ] ) do
134134 GenServer . call ( client , { :connect , server , port , options , true } , :infinity )
135135 end
136136
137137 @ doc """
138138 Determine if the provided client process has an open connection to a server
139139 """
140- @ spec is_connected? ( client :: pid ) :: true | false
140+ @ spec is_connected? ( client :: pid ) :: boolean
141141 def is_connected? ( client ) do
142142 GenServer . call ( client , :is_connected? )
143143 end
@@ -160,7 +160,7 @@ defmodule ExIRC.Client do
160160 @ doc """
161161 Determine if the provided client is logged on to a server.
162162 """
163- @ spec is_logged_on? ( client :: pid ) :: true | false
163+ @ spec is_logged_on? ( client :: pid ) :: boolean | { :error , :not_connected }
164164 def is_logged_on? ( client ) do
165165 GenServer . call ( client , :is_logged_on? )
166166 end
@@ -174,76 +174,80 @@ defmodule ExIRC.Client do
174174 * `:ctcp`
175175
176176 """
177- @ spec msg ( client :: pid , type :: atom , nick :: binary , msg :: binary ) :: :ok
177+ @ spec msg ( client :: pid , type :: atom , nick :: binary , msg :: binary ) ::
178+ :ok | { :error , :not_connected | :not_logged_in }
178179 def msg ( client , type , nick , msg ) do
179180 GenServer . call ( client , { :msg , type , nick , msg } , :infinity )
180181 end
181182
182183 @ doc """
183184 Send an action message, i.e. (/me slaps someone with a big trout).
184185 """
185- @ spec me ( client :: pid , channel :: binary , msg :: binary ) :: :ok
186+ @ spec me ( client :: pid , channel :: binary , msg :: binary ) ::
187+ :ok | { :error , :not_connected | :not_logged_in }
186188 def me ( client , channel , msg ) do
187189 GenServer . call ( client , { :me , channel , msg } , :infinity )
188190 end
189191
190192 @ doc """
191193 Change the client's nick.
192194 """
193- @ spec nick ( client :: pid , new_nick :: binary ) :: :ok
195+ @ spec nick ( client :: pid , new_nick :: binary ) :: :ok | { :error , :not_connected }
194196 def nick ( client , new_nick ) do
195197 GenServer . call ( client , { :nick , new_nick } , :infinity )
196198 end
197199
198200 @ doc """
199201 Send a raw IRC command.
200202 """
201- @ spec cmd ( client :: pid , raw_cmd :: binary ) :: :ok
203+ @ spec cmd ( client :: pid , raw_cmd :: binary ) :: :ok | { :error , :not_connected | :not_logged_in }
202204 def cmd ( client , raw_cmd ) do
203205 GenServer . call ( client , { :cmd , raw_cmd } )
204206 end
205207
206208 @ doc """
207209 Join a channel, with an optional password.
208210 """
209- @ spec join ( client :: pid , channel :: binary , key :: binary | nil ) :: :ok
211+ @ spec join ( client :: pid , channel :: binary , key :: binary | nil ) ::
212+ :ok | { :error , :not_connected | :not_logged_in }
210213 def join ( client , channel , key \\ "" ) do
211214 GenServer . call ( client , { :join , channel , key } , :infinity )
212215 end
213216
214217 @ doc """
215218 Leave a channel.
216219 """
217- @ spec part ( client :: pid , channel :: binary ) :: :ok
220+ @ spec part ( client :: pid , channel :: binary ) :: :ok | { :error , :not_connected | :not_logged_in }
218221 def part ( client , channel ) do
219222 GenServer . call ( client , { :part , channel } , :infinity )
220223 end
221224
222225 @ doc """
223226 Kick a user from a channel.
224227 """
225- @ spec kick ( client :: pid , channel :: binary , nick :: binary , message :: binary | nil ) :: :ok
228+ @ spec kick ( client :: pid , channel :: binary , nick :: binary , message :: binary | nil ) ::
229+ :ok | { :error , :not_connected | :not_logged_in }
226230 def kick ( client , channel , nick , message \\ "" ) do
227231 GenServer . call ( client , { :kick , channel , nick , message } , :infinity )
228232 end
229233
230- @ spec names ( client :: pid , channel :: binary ) :: :ok
234+ @ spec names ( client :: pid , channel :: binary ) :: :ok | { :error , :not_connected | :not_logged_in }
231235 def names ( client , channel ) do
232236 GenServer . call ( client , { :names , channel } , :infinity )
233237 end
234238
235239 @ doc """
236240 Ask the server for the user's informations.
237241 """
238- @ spec whois ( client :: pid , user :: binary ) :: :ok
242+ @ spec whois ( client :: pid , user :: binary ) :: :ok | { :error , :not_connected | :not_logged_in }
239243 def whois ( client , user ) do
240244 GenServer . call ( client , { :whois , user } , :infinity )
241245 end
242246
243247 @ doc """
244248 Ask the server for the channel's users.
245249 """
246- @ spec who ( client :: pid , channel :: binary ) :: :ok
250+ @ spec who ( client :: pid , channel :: binary ) :: :ok | { :error , :not_connected | :not_logged_in }
247251 def who ( client , channel ) do
248252 GenServer . call ( client , { :who , channel } , :infinity )
249253 end
@@ -252,55 +256,60 @@ defmodule ExIRC.Client do
252256 Change mode for a user or channel.
253257 """
254258 @ spec mode ( client :: pid , channel_or_nick :: binary , flags :: binary , args :: binary | nil ) ::
255- :ok
259+ :ok | { :error , :not_connected | :not_logged_in }
256260 def mode ( client , channel_or_nick , flags , args \\ "" ) do
257261 GenServer . call ( client , { :mode , channel_or_nick , flags , args } , :infinity )
258262 end
259263
260264 @ doc """
261265 Invite a user to a channel.
262266 """
263- @ spec invite ( client :: pid , nick :: binary , channel :: binary ) :: :ok
267+ @ spec invite ( client :: pid , nick :: binary , channel :: binary ) ::
268+ :ok | { :error , :not_connected | :not_logged_in }
264269 def invite ( client , nick , channel ) do
265270 GenServer . call ( client , { :invite , nick , channel } , :infinity )
266271 end
267272
268273 @ doc """
269274 Quit the server, with an optional part message.
270275 """
271- @ spec quit ( client :: pid , msg :: binary | nil ) :: :ok
276+ @ spec quit ( client :: pid , msg :: binary | nil ) ::
277+ :ok | { :error , :not_connected | :not_logged_in }
272278 def quit ( client , msg \\ "Leaving.." ) do
273279 GenServer . call ( client , { :quit , msg } , :infinity )
274280 end
275281
276282 @ doc """
277283 Get details about each of the client's currently joined channels.
278284 """
279- @ spec channels ( client :: pid ) :: [ binary ]
285+ @ spec channels ( client :: pid ) :: [ binary ] | { :error , :not_connected | :not_logged_in }
280286 def channels ( client ) do
281287 GenServer . call ( client , :channels )
282288 end
283289
284290 @ doc """
285291 Get a list of users in the provided channel.
286292 """
287- @ spec channel_users ( client :: pid , channel :: binary ) :: [ binary ] | { :error , atom }
293+ @ spec channel_users ( client :: pid , channel :: binary ) ::
294+ [ binary ] | { :error , :not_connected | :not_logged_in | :no_such_channel }
288295 def channel_users ( client , channel ) do
289296 GenServer . call ( client , { :channel_users , channel } )
290297 end
291298
292299 @ doc """
293300 Get the topic of the provided channel.
294301 """
295- @ spec channel_topic ( client :: pid , channel :: binary ) :: binary | { :error , atom }
302+ @ spec channel_topic ( client :: pid , channel :: binary ) ::
303+ binary | { :error , :not_connected | :not_logged_in | :no_such_channel }
296304 def channel_topic ( client , channel ) do
297305 GenServer . call ( client , { :channel_topic , channel } )
298306 end
299307
300308 @ doc """
301309 Get the channel type of the provided channel.
302310 """
303- @ spec channel_type ( client :: pid , channel :: binary ) :: atom | { :error , atom }
311+ @ spec channel_type ( client :: pid , channel :: binary ) ::
312+ atom | { :error , :not_connected | :not_logged_in | :no_such_channel }
304313 def channel_type ( client , channel ) do
305314 GenServer . call ( client , { :channel_type , channel } )
306315 end
@@ -309,7 +318,7 @@ defmodule ExIRC.Client do
309318 Determine if a nick is present in the provided channel.
310319 """
311320 @ spec channel_has_user? ( client :: pid , channel :: binary , nick :: binary ) ::
312- boolean | { :error , atom }
321+ boolean | { :error , :not_connected | :not_logged_in | :no_such_channel }
313322 def channel_has_user? ( client , channel , nick ) do
314323 GenServer . call ( client , { :channel_has_user? , channel , nick } )
315324 end
0 commit comments