Module: Krtek::Irc::Commands::RFC1459
- Included in:
- Krtek::Irc::Client
- Defined in:
- lib/krtek/commands.rb
Instance Method Summary collapse
- #join(*args) ⇒ Object
-
#nick(nick = nil) ⇒ Object
Command: NICK tools.ietf.org/html/rfc1459.html#section-4.1.2.
- #ping(server, target = '') ⇒ Object
- #pong(*servers) ⇒ Object
- #privmsg(target, message) ⇒ Object
- #server_connect(target, port, remote = nil) ⇒ Object
-
#user(username, hostname, servername, realname) ⇒ Object
Command: USER Parameters: <username> <hostname> <servername> <realname>.
Instance Method Details
#join(*args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/krtek/commands.rb', line 22 def join(*args) raise ArgumentError.new("Not enough arguments") unless args.size > 0 channels, keys = [], [] args.map! {|arg| arg.is_a?(Array) ? arg : [arg, '']} args.sort! {|a,b| b[1].length <=> a[1].length} # key channels first args.each {|arg| channels << arg[0] keys << arg[1] if arg[1].length > 0 } send_data("JOIN #{channels.join(',')} #{keys.join(',')}".strip) end |
#nick(nick = nil) ⇒ Object
Command: NICK tools.ietf.org/html/rfc1459.html#section-4.1.2
7 8 9 10 11 12 13 |
# File 'lib/krtek/commands.rb', line 7 def nick(nick = nil) if nick send_data("NICK #{nick}") else @nick end end |
#ping(server, target = '') ⇒ Object
42 43 44 |
# File 'lib/krtek/commands.rb', line 42 def ping(server, target = '') send_data("PING #{server} #{target}".strip) end |
#pong(*servers) ⇒ Object
38 39 40 |
# File 'lib/krtek/commands.rb', line 38 def pong(*servers) send_data("PONG #{servers.join(' ')}") end |
#privmsg(target, message) ⇒ Object
34 35 36 |
# File 'lib/krtek/commands.rb', line 34 def privmsg(target, ) send_data("PRIVMSG #{target} :#{}") end |
#server_connect(target, port, remote = nil) ⇒ Object
46 47 48 |
# File 'lib/krtek/commands.rb', line 46 def server_connect(target, port, remote = nil) send_data("CONNECT #{target} #{port} #{remote}".strip) end |
#user(username, hostname, servername, realname) ⇒ Object
Command: USER Parameters: <username> <hostname> <servername> <realname>
17 18 19 20 |
# File 'lib/krtek/commands.rb', line 17 def user(username, hostname, servername, realname) # send_data("USER #{username} #{hostname} #{servername} :#{realname}") send_data("USER #{username} tolmoon tolsun lol :Ronnie Reagan") end |