Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

IRC client that uses EventMachine to handle connections to servers

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib fix bad away command March 31, 2012
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 .yardopts
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Guardfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 em-irc.gemspec
README.md

EventMachine IRC Client

Build Status

em-irc is an IRC client that uses EventMachine to handle connections to servers.

Basic Usage

require 'em-irc'

client = EventMachine::IRC::Client.new do
  host 'irc.freenode.net'
  port '6667'

  on(:connect) do
    nick('jch')
  end

  on(:nick) do
    join('#general')
    join('#private', 'key')
  end

  on(:join) do |channel|  # called after joining a channel
    message(channel, "howdy all")
  end

  on(:message) do |source, target, message|  # called when being messaged
    puts "<#{source}> -> <#{target}>: #{message}"
  end

  # callback for all messages sent from IRC server
  on(:parsed) do |hash|
    puts "#{hash[:prefix]} #{hash[:command]} #{hash[:params].join(' ')}"
  end
end

client.run!  # start EventMachine loop

Alternatively, if local variable access is needed, the first block variable is the client:

client = EventMachine::IRC::Client.new do |c|
  # c is the client instance
end

Examples

See examples folder for examples. These are directly runnable. For example, to run the interactive command line client:

ruby examples/interactive.rb

References

Platforms

The following platforms are tentatively supported:

  • 1.8.7
  • 1.9.2
  • 1.9.3
  • ree
  • Rubinius

I currently develop ruby 1.9.3, so it'll be the VM that gets the most support.

Development

To run integration specs, you'll need to run a ssl and a non-ssl irc server locally. On OSX, you can install a server via Homebrew with:

bundle
brew install ngircd
ngircd -f spec/config/ngircd-unencrypted.conf
ngircd -f spec/config/ngircd-encrypted-openssl.conf
bundle exec rake  # or guard

If the server is not starting up correctly, make sure you're ngircd is compiled with openssl support rather than gnutls. You can see the server boot output by passing the '-n' flag. Also not that travis-ci builds are executed with gnutls.

License

Copyright (c) 2012 Jerry Cheung.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.