• Stars
    star
    20
  • Rank 1,085,592 (Top 23 %)
  • Language
    Crystal
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast IRC parsing library for crystal.

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

More Repositories

1

parallel.cr

Parallelism for crystal as a shard
Crystal
62
star
2

camo.cr

A crystal version of atmos/camo, faster and with better request lifecycle tracing
Crystal
39
star
3

discord-curses

Terminal-based discord client (abandoned)
TypeScript
26
star
4

predict.cr

Satellite prediction library for crystal using the sgp4 model
C++
17
star
5

coz.cr

Crystal
17
star
6

multipart.cr

MIME multipart and multipart/form-data support for Crystal
Crystal
10
star
7

jMCLaunchLib

Launch Minecraft from the JVM. With a library.
Groovy
9
star
8

crane

WIP Crystal version manager
Crystal
5
star
9

Kitsune

Crystal
3
star
10

dotfiles

git clone --bare https://github.com/RX14/dotfiles ~/.local/share/dotfiles && git --git-dir="$HOME/.local/share/dotfiles" --work-tree="$HOME" checkout
Shell
3
star
11

RX14

Issue tracker dedicated to the chibi with the alias of RX14
2
star
12

rory

Crystal
2
star
13

rx14.co.uk

Source for rx14.co.uk
HTML
2
star
14

PS2-lib

A PS/2 library for Arduino, with Mouse and Keyboard libraries.
C++
2
star
15

pomfire

B2-backed caching (incomplete) pomf
Crystal
2
star
16

ModMaven

Gradle Scripts to upload minecraft mod libraries to a maven repository.
Shell
2
star
17

clamd.cr

Crystal
2
star
18

guix-docker

Shell
1
star
19

wifi-headphones

Jupyter Notebook
1
star
20

MangaCrawler

C#
1
star
21

docker-alpine-crystal

Shell
1
star
22

genetic-algorithm-test

Crystal
1
star
23

docker-jenkins-slave

Shell
1
star
24

clamd-continuousd

Crystal
1
star
25

L298N-lib

Arduino library for using the L298N motor driver
C++
1
star
26

satserver-api

Crystal
1
star
27

kurisu.rx14.co.uk

Shell
1
star
28

pomf-standard

1
star
29

gwt

Crystal
1
star
30

kagi-developer-assement

HTML
1
star
31

SWRChart

A VB.net Program for Charting Frequency/SWR values over COM.
Visual Basic
1
star
32

gd32vf103-devboard

1
star
33

crystal-jenkins

Shell
1
star
34

rpn.cr

Crystal
1
star
35

kepala

Crystal
1
star
36

environment-sensor

HTML
1
star