Project

em-irc

No commit activity in last 3 years
No release in over 3 years
em-irc is an IRC client that uses EventMachine to handle connections to servers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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.