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

authenticate(method = :plain) click to toggle source

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
cap_end() click to toggle source

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(msg = 'Closing connection') click to toggle source

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(chan, key = nil) click to toggle source

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
nickname=(new) click to toggle source

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
pass(password;) click to toggle source

Supply server password.

@param [String] pass

# File lib/syndi/irc/std/commands.rb, line 73
def pass password; snd "PASS :#{password}"; end
user(username, hostname=Socket.gethostname, server, realname) click to toggle source

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
who() click to toggle source

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