All Projects → RX14 → fast_irc.cr

RX14 / fast_irc.cr

Licence: MIT License
A fast IRC parsing library for crystal.

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to fast irc.cr

Irssi
The client of the future
Stars: ✭ 2,431 (+13405.56%)
Mutual labels:  irc, irc-protocol
parser-tests
Tests for IRC Parsers
Stars: ✭ 35 (+94.44%)
Mutual labels:  irc, irc-protocol
ircv3.github.io
IRCv3 website
Stars: ✭ 85 (+372.22%)
Mutual labels:  irc, irc-protocol
erk
Ərk is an open source, cross-platform IRC client written in Python 3, Qt 5, and Twisted.
Stars: ✭ 21 (+16.67%)
Mutual labels:  irc
thelounge-deb
📦 ‎ Debian/Ubuntu package for The Lounge
Stars: ✭ 16 (-11.11%)
Mutual labels:  irc
lita-irc
An IRC adapter for Lita.
Stars: ✭ 19 (+5.56%)
Mutual labels:  irc
vegasflow
VegasFlow: accelerating Monte Carlo simulation across multiple hardware platforms
Stars: ✭ 19 (+5.56%)
Mutual labels:  efficiency
irc-tts
Broadcast your IRC channel via a text-to-speech webserver
Stars: ✭ 14 (-22.22%)
Mutual labels:  irc
Lith
WeeChat relay client
Stars: ✭ 32 (+77.78%)
Mutual labels:  irc
FormTracer
A Mathematica Tracing Package Using FORM
Stars: ✭ 16 (-11.11%)
Mutual labels:  efficiency
yesbot
IRC Bot Written in Prolog
Stars: ✭ 19 (+5.56%)
Mutual labels:  irc
irc.dart
Dart IRC Library
Stars: ✭ 45 (+150%)
Mutual labels:  irc
irc-go
Libraries to help with IRC development in Go.
Stars: ✭ 22 (+22.22%)
Mutual labels:  irc
st2chatops
Packaging environment for building StackStorm chatops native packages
Stars: ✭ 26 (+44.44%)
Mutual labels:  irc
websites
🔗 Effective Websites Collections
Stars: ✭ 55 (+205.56%)
Mutual labels:  efficiency
teleirc
Go implementation of a Telegram <=> IRC bridge for use with any IRC channel and Telegram group
Stars: ✭ 112 (+522.22%)
Mutual labels:  irc
godot-twicil
Godot TwiCIL – Godot Twitch Chat Interaction Layer
Stars: ✭ 57 (+216.67%)
Mutual labels:  irc
limnoria-plugins
Limnoria plugins I wrote or forked.
Stars: ✭ 35 (+94.44%)
Mutual labels:  irc
hlc
An open-source web page highlighter
Stars: ✭ 32 (+77.78%)
Mutual labels:  efficiency
twitch-chatlog
Fetch the chatlog to a twitch VOD from your command line.
Stars: ✭ 78 (+333.33%)
Mutual labels:  irc

Travis CI

fast_irc.cr

An optimised IRC parsing library for crystal. Supports IRCv3 message tags. Getting started is as easy as FastIRC.parse(io) do |message|.

Fast_irc doesn't attempt to deal with the semantics of IRC messages. Messages are simply parsed into a machine-readable format and delivered to the user.

Performance

Here fast_irc was tested parsing a 63748 byte IRC log file collected from real IRC activity on the esper.net IRC network. Fast_irc's performance on a single core averaged over 150MB/s, taking only 740 nanoseconds to parse a single line.

In terms of memory performance, a single 8192 byte buffer is allocated per connection. All string values in the IRC prefix, the IRC command, and IRCv3 tag keys are interned in a global string pool to save memory. IRCv3 message tag values and IRC command parameters are not interned.

Installation

Add it to shard.yml

dependencies:
  fast_irc:
    github: RX14/fast_irc.cr
    version: 0.3.4

Docs

Build the documentation by cloning this repo and running crystal doc. HTML documentation will be placed in doc/.

Usage

It's easy to get started parsing IRC connections right away using fast_irc. Just pass an IO (likely a TCP connection to an IRC server) to FastIRC.parse. Message objects are yielded as they arrive on the connection. For a non-block way to read messages, see FastIRC::Reader.

FastIRC.parse(io) do |message|
  message.command       # => "PRIVMSG" : String
  message.params        # => ["#crystal-lang", "Test message using fast_irc.cr!"] : Array(String)?
  message.prefix.source # => "RX14" : String
end

Generating IRC is just as easy. Create your Message object and call to_s.

FastIRC::Message.new("PRIVMSG", ["#WAMM", "test message"]).to_s(io)

You can also add IRCv3 tags and a prefix. FastIRC::Tags is simply an alias for Hash(String, String?). It is recommended to use the FastIRC::Tags alias when creating tags hashes both to clear intent, and to make sure that you don't end up with a Hash(String, String) instead, which is a binary-incompatible type.

prefix = FastIRC::Prefix.new(source: "RX14", user: "rx14", host: "rx14.co.uk")
tags = FastIRC::Tags{"time" => "2016-11-11T22:27:15Z"}
FastIRC::Message.new("PRIVMSG", ["#WAMM", "test message"], prefix: prefix, tags: tags).to_s(io)

Contributing

  1. Fork it ( https://github.com/RX14/fast_irc/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • RX14 Stephanie Wilde-Hobbs - creator, maintainer
  • Kilobyte22 Stephan Henrichs - IRC serialisation, specs
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].