Git Product home page Git Product logo

irc_lib's Introduction

Irc client library for erlang

irc_lib - is irc client library for erlang application. It provides simple functional for communicating with irc servers.

Build Status

Features

  • Simple connect to irc channel
  • OTP overall
  • Auto PING/PONG
  • Send irc message api
  • Callbacks
  • SSL support
  • Reconnect ability
  • Dependency free

Usage

First of all compile irc lib:

./rebar compile

Start root supervisor in your project or application:

irc_lib_sup:start_link().

Now create callback module which will be run and receive incoming irc messages:

-module(irc_test).

-behavior(gen_server).

-export([start_link/0]).
 
%% gen_server callbacks
-export([init/1,
         handle_call/3,
         handle_cast/2,
         handle_info/2,
         terminate/2,
         code_change/3]).
 
% state
-record(state, {}).

start_link() ->
    gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).

init([]) ->
	irc_lib_sup:start_link(),
	irc_lib_sup:start_irc_client(?MODULE, <<"irc.freenode.net">>, 5667, false, <<"#erlang">>, <<"some-user-name">>, false, 1000),
    {ok, #state{}}.
 
handle_call(_Request, _From, State) ->
    {reply, ignored, State}.

handle_cast(_Msg, State) ->
    {noreply, State}.

handle_info({incoming_message, From, IncomingMessage}, State) ->
	io:format("Incoming message: ~p ~p ~n", [IncomingMessage, From]),
	{noreply, State};

handle_info(_Info, State) ->
    {noreply, State}.

terminate(_Reason, _State) ->
    ok.

code_change(_OldVsn, State, _Extra) ->
    {ok, State}.
 
%% Internal functions

Also sending message to irc channel:

irc_lib_client:send_message(Pid, <<"Hello erlangers">>).

Where Pid - is pid of irc client process.

Contribute

  • Fork irc_lib repo
  • Make changes
  • Pull request
  • Thank you.

Authors

@0xAX

irc_lib's People

Contributors

anws avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.