Meoowww / Crirc

Migrated to https://git.sceptique.eu/Sceptique/Crirc
GNU Affero General Public License v3.0
21 stars 6 forks source link

Investigate using fast_irc.cr to parse messages #9

Open RX14 opened 6 years ago

RX14 commented 6 years ago

See https://github.com/veelenga/awesome-crystal/pull/240.

Better to keep the communication here and away from the awesome-crystal repo.

Nephos commented 6 years ago

Ok thanks :)

Nephos commented 6 years ago

I think you could build the parameters of the message from a Enum(String) instead of Array(String).

RX14 commented 6 years ago

@Nephos I assume you mean Enumberable.

Maybe, but currently the way to serialize an IRC message is to create a new Message struct then call to_s. It would be ugly and inefficient to make the instance variable for args an Enumberable, but converting it to an array silently in the constructor would be a bit off too.

Perhaps extracting generating IRC from Message#to_s to a more generic method that took generic Enumerable would be a better solution, but perhaps a bit ugly to use. I think i'll do it though:

FastIRC.serialize(command : String, params : Enumberable(String) = Tuple.new) : String
FastIRC.serialize(command : String, *, params : Enumberable(String) = Tuple.new, source : String, user : String? = nil, host : String? = nil) : String
FastIRC.serialize(io : IO, command : String, params : Enumberable(String) = Tuple.new) : Nil
FastIRC.serialize(io : IO, command : String, *, params : Enumberable(String) = Tuple.new, source : String, user : String? = nil, host : String? = nil) : Nil

is probably how i'd do the interface

RX14 commented 6 years ago

I see though that your way of representing IRC is quite different to the RFC's:

   NOTES:
      1) After extracting the parameter list, all parameters are equal
         whether matched by <middle> or <trailing>. <trailing> is just a
         syntactic trick to allow SPACE within the parameter.

whereas you always treat the trailing "message" parameter differently.

Nephos commented 6 years ago

The RFC is more what you call guidelines, than actual rules :) I'm looking for using fast_irc in the hooking system, it might require some time to change the current implementation.

RX14 commented 6 years ago

@Nephos sure, but I think the protocol part of the RFC is fairly well agreed on.

Nephos commented 6 years ago

(that was a reference to Pirate of C.) Well you must be right. I'll see

RX14 commented 6 years ago

@Nephos I feel stupid for missing that reference haha

Nephos commented 6 years ago

I've a lot of work these days, so I don't think I'll do it before at least 30 more days. Too much stuff to handle at once, you know what it is ;)

RX14 commented 6 years ago

@Nephos that's fine, it was just an interesting suggestion.