Module: Syndi::IRC::Std::Commands
- Defined in:
- lib/syndi/irc/std/commands.rb
Overview
A module which provides a number of methods for basic IRC commands, intended for inclusion in Syndi::IRC::Server.
Instance Method Summary collapse
-
#authenticate(method = :plain) ⇒ Object
Send initial AUTHENTICATE.
-
#cap_end ⇒ Object
Send CAP END.
-
#disconnect(msg = 'Closing connection') ⇒ Object
Disconnect from the server.
-
#join(chan, key = nil) ⇒ Object
Join a channel on the server.
-
#nickname=(new) ⇒ Object
Send /NICK to change the bot's nickname on the server.
-
#pass(password) ⇒ Object
Supply server password.
-
#user(username, hostname = Socket.gethostname, server, realname) ⇒ Object
Send /USER.
-
#who ⇒ Object
Request a /WHO on ourselves.
Instance Method Details
#authenticate(method = :plain) ⇒ Object
Send initial AUTHENTICATE.
15 16 17 18 19 20 21 22 23 |
# File 'lib/syndi/irc/std/commands.rb', line 15 def authenticate method = :plain if method == :plain snd 'AUTHENTICATE PLAIN' @supp.sasl_method = :plain elsif method == :dh_blowfish snd 'AUTHENTICATE DH-BLOWFISH' @supp.sasl_method = :dh_blowfish end end |
#cap_end ⇒ Object
Send CAP END.
26 27 28 29 30 31 |
# File 'lib/syndi/irc/std/commands.rb', line 26 def cap_end # Stop any SASL-related timers @supp.sasl_id.each { |t| $m.clock.del t } # Send CAP END snd 'CAP END' end |
#disconnect(msg = 'Closing connection') ⇒ Object
Disconnect from the server.
36 37 38 39 40 |
# File 'lib/syndi/irc/std/commands.rb', line 36 def disconnect msg = 'Closing connection' emit :irc, :disconnect, self, msg snd "QUIT :#{msg}" @socket = nil end |
#join(chan, key = nil) ⇒ Object
Join a channel on the server.
46 47 48 49 |
# File 'lib/syndi/irc/std/commands.rb', line 46 def join chan, key = nil snd "JOIN #{chan}#{key.nil? ? '' : key}" emit :irc, :send_join, self, chan, key end |
#nickname=(new) ⇒ Object
Note:
If the nickname is in use, the bot will append a hyphen and retry, repeating until success is achieved.
Send /NICK to change the bot's nickname on the server.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/syndi/irc/std/commands.rb', line 57 def nickname= new if connected? @newnick = new else @nick = new end snd "NICK :#{new}" emit :irc, :send_nick, self, new end |
#pass(password) ⇒ Object
Supply server password.
73 |
# File 'lib/syndi/irc/std/commands.rb', line 73 def pass password; snd "PASS :#{password}"; end |
#user(username, hostname = Socket.gethostname, server, realname) ⇒ Object
Send /USER.
81 82 83 |
# File 'lib/syndi/irc/std/commands.rb', line 81 def user username, hostname=Socket.gethostname, server, realname snd "USER #{username} #{hostname} #{server} :#{realname}" end |
#who ⇒ Object
Request a /WHO on ourselves.
86 87 88 89 |
# File 'lib/syndi/irc/std/commands.rb', line 86 def who snd "WHO #@nick" emit :irc, :who_self, self end |