module Syndi::IRC::Std::Commands
A module which provides a number of methods for basic IRC
commands, intended for inclusion in {Syndi::IRC::Server}.
Public Instance Methods
Send initial AUTHENTICATE.
# 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
Send CAP END.
# 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 from the server.
@param [String] msg Reason for disconnect.
# 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 a channel on the server.
@param [String] chan Channel to join. @param [String] key Key to join, if necessary.
# 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
Send /NICK to change the bot's nickname on the server.
@note If the nickname is in use, the bot will append a hyphen and retry,
repeating until success is achieved.
@param [String] new The new nickname.
# 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
Supply server password.
@param [String] pass
# File lib/syndi/irc/std/commands.rb, line 73 def pass password; snd "PASS :#{password}"; end
Send /USER.
@param [String] username The bot's username or ident. @param [String] hostname The bot's hostname. @param [String] server Address of the remote server. @param [String] realname The bot's real name or GECOS.
# File lib/syndi/irc/std/commands.rb, line 81 def user username, hostname=Socket.gethostname, server, realname snd "USER #{username} #{hostname} #{server} :#{realname}" end
Request a /WHO on ourselves.
# File lib/syndi/irc/std/commands.rb, line 86 def who snd "WHO #@nick" emit :irc, :who_self, self end