Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F665868
exirc.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
exirc.ex
View Options
defmodule
ExIrc
do
@moduledoc
"""
Supervises IRC client processes
Usage:
#
Start the supervisor (started automatically when ExIrc is run as an application)
ExIrc.start_link
#
Start a new IRC client
{:ok, client} = ExIrc.start_client!
#
Connect to an IRC server
ExIrc.Client.connect! client, "localhost", 6667
#
Logon
ExIrc.Client.logon client, "password", "nick", "user", "name"
#
Join a channel (password is optional)
ExIrc.Client.join client, "
#
channel", "password"
#
Send a message
ExIrc.Client.msg client, :privmsg, "
#
channel", "Hello world!"
#
Quit (message is optional)
ExIrc.Client.quit client, "message"
#
Stop and close the client connection
ExIrc.Client.stop! client
"""
use
Supervisor
##############
# Public API
##############
@doc
"""
Start the ExIrc supervisor.
"""
@spec
start!
::
{
:ok
,
pid
}
|
{
:error
,
term
}
def
start!
do
:supervisor
.
start_link
({
:local
,
:exirc
},
__MODULE__
,
[])
end
@doc
"""
Start a new ExIrc client
"""
@spec
start_client!
::
{
:ok
,
pid
}
|
{
:error
,
term
}
def
start_client!
do
# Start the client worker
:supervisor
.
start_child
(
:exirc
,
worker
(
ExIrc.Client
,
[]))
end
##############
# Supervisor API
##############
@spec
init
(
any
)
::
{
:ok
,
pid
}
|
{
:error
,
term
}
def
init
(
_
)
do
supervise
[],
strategy
:
:one_for_one
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sat, Feb 28, 9:56 AM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
87367
Default Alt Text
exirc.ex (1 KB)
Attached To
rEXIRC ExIRC Fork
Event Timeline
Log In to Comment