Compare commits
2 Commits
master
...
feature/fa
Author | SHA1 | Date | |
---|---|---|---|
8df53b2140 | |||
af236d5989 |
|
@ -23,10 +23,10 @@ Then, run ``crystal deps install`` to fetch the lib.
|
|||
|
||||
## Development
|
||||
|
||||
- Network: A network object manage a socket / IO
|
||||
- Controller: A controller belongs to a network object, and handle the logic and data
|
||||
- Protocol: A protocol object represent a IRC entity (chan, user, message, ...)
|
||||
- Binding: The binding socket to allow the system to respond to incoming transmissions
|
||||
- `Network`: A network object manage a socket / IO
|
||||
- `Controller`: A controller belongs to a network object, and handle the logic and data
|
||||
- `Protocol`: A protocol object represent a IRC entity (chan, user, message, ...)
|
||||
- `Binding`: The binding socket to allow the system to respond to incoming transmissions
|
||||
|
||||
|
||||
## Contributing
|
||||
|
|
|
@ -6,4 +6,9 @@ authors:
|
|||
|
||||
crystal: 0.23.1
|
||||
|
||||
license: MIT
|
||||
license: GPLv3
|
||||
|
||||
dependencies:
|
||||
fast_irc:
|
||||
github: RX14/fast_irc.cr
|
||||
version: 0.3.3
|
||||
|
|
|
@ -12,9 +12,9 @@ describe Crirc::Controller::Command::Chan do
|
|||
chan = Crirc::Protocol::Chan.new "#patate"
|
||||
chan2 = Crirc::Protocol::Chan.new "#nyu"
|
||||
|
||||
Crirc::Test::Controller::Command::Chan.join({chan}).should eq("JOIN #patate")
|
||||
Crirc::Test::Controller::Command::Chan.join(chan).should eq("JOIN #patate")
|
||||
Crirc::Test::Controller::Command::Chan.join({chan, chan2}).should eq("JOIN #patate,#nyu")
|
||||
Crirc::Test::Controller::Command::Chan.join({chan}).should eq("JOIN #patate :")
|
||||
Crirc::Test::Controller::Command::Chan.join(chan).should eq("JOIN #patate :")
|
||||
Crirc::Test::Controller::Command::Chan.join({chan, chan2}).should eq("JOIN #patate,#nyu :")
|
||||
Crirc::Test::Controller::Command::Chan.join({chan}, {"bloup"}).should eq("JOIN #patate bloup")
|
||||
Crirc::Test::Controller::Command::Chan.join({chan, chan2}, {"bloup", "blip"}).should eq("JOIN #patate,#nyu bloup,blip")
|
||||
end
|
||||
|
|
17
src/crirc.cr
17
src/crirc.cr
|
@ -1,5 +1,22 @@
|
|||
require "fast_irc"
|
||||
|
||||
# Contains the classes that handle the network layer.
|
||||
# They establish the connexion, fetch and send the messages data, etc.
|
||||
module Crirc::Network
|
||||
end
|
||||
require "./crirc/network/*"
|
||||
|
||||
# Contains the logic of the irc client or server (initialisation, authentication, etc.).
|
||||
# a Controller is created by a Network object.
|
||||
module Crirc::Controller
|
||||
end
|
||||
require "./crirc/controller/*"
|
||||
|
||||
# Contains atomic elements such as Chan, User, or Message.
|
||||
# Those can be used to interact with the `Crirc::Command` modules and `Crirc::Binding`.
|
||||
module Crirc::Protocol
|
||||
end
|
||||
require "./crirc/protocol/*"
|
||||
|
||||
require "./crirc/broadcast/*"
|
||||
require "./crirc/binding/*"
|
||||
|
|
|
@ -13,7 +13,8 @@ module Crirc::Controller::Command::Chan
|
|||
def join(chans : Enumerable(Crirc::Protocol::Chan), passwords : Enumerable(String) = [""])
|
||||
to_join = format_list(chans)
|
||||
passes = passwords.join(",")
|
||||
puts "JOIN #{to_join} #{passes}"
|
||||
puts FastIRC::Message.new("JOIN", [to_join, passes]).to_s # TODO: use to_s(io)
|
||||
#puts "JOIN #{to_join} #{passes}"
|
||||
end
|
||||
|
||||
# Overloads the join function for 1 chan.
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
# Message is a class that handles the data sent through the network.
|
||||
# It is parsed to provide access to specific parts of the data.
|
||||
class Crirc::Protocol::Message
|
||||
# The raw data without parsing
|
||||
getter raw : String
|
||||
|
||||
# The source of the message (ex: uuidxxx@moz-stuff.net)
|
||||
getter source : String
|
||||
|
||||
# The command / response (ex: PRIVMSG or 535)
|
||||
getter command : String
|
||||
|
||||
# The arguments (not parsed) as a simple string. If there are no arguments in
|
||||
# the message, then it is nil
|
||||
getter arguments : String?
|
||||
|
||||
# The last argument of the message if it begins with :, or nil if none.
|
||||
getter message : String?
|
||||
|
||||
R_SRC = "(\\:(?<src>[^[:space:]]+) )"
|
||||
|
@ -28,6 +40,7 @@ class Crirc::Protocol::Message
|
|||
return "#{@arguments} :#{@message}"
|
||||
end
|
||||
|
||||
# The list of the arguments parsed as an Array of String. Empty if no arguments
|
||||
def argument_list : Array(String)
|
||||
return Array(String).new if @arguments.nil? && @message.nil?
|
||||
return (@arguments.as(String)).split(" ") if @message.nil?
|
||||
|
|
Loading…
Reference in New Issue
Block a user