Class: Cinch::Plugins::BasicCTCP

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/basic_ctcp.rb

Instance Method Summary collapse

Instance Method Details

#ctcp_clientinfo(m) ⇒ Object


29
30
31
# File 'lib/cinch/plugins/basic_ctcp.rb', line 29

def ctcp_clientinfo(m)
  m.ctcp_reply "ACTION PING VERSION TIME CLIENTINFO SOURCE" if reply_to_ctcp?(:clientinfo)
end

#ctcp_ping(m) ⇒ Object


21
22
23
# File 'lib/cinch/plugins/basic_ctcp.rb', line 21

def ctcp_ping(m)
  m.ctcp_reply m.ctcp_args.join(" ") if reply_to_ctcp?(:ping)
end

#ctcp_source(m) ⇒ Object


25
26
27
# File 'lib/cinch/plugins/basic_ctcp.rb', line 25

def ctcp_source(m)
  m.ctcp_reply "http://github.com/cinchrb/cinch" if reply_to_ctcp?(:source)
end

#ctcp_time(m) ⇒ Object


17
18
19
# File 'lib/cinch/plugins/basic_ctcp.rb', line 17

def ctcp_time(m)
  m.ctcp_reply Time.now.strftime("%a %b %d %H:%M:%S %Z %Y") if reply_to_ctcp?(:time)
end

#ctcp_version(m) ⇒ Object


13
14
15
# File 'lib/cinch/plugins/basic_ctcp.rb', line 13

def ctcp_version(m)
  m.ctcp_reply "Cinch v#{Cinch::VERSION}" if reply_to_ctcp?(:version)
end

#reply_to_ctcp?(command) ⇒ Boolean

Returns:

  • (Boolean)

33
34
35
36
# File 'lib/cinch/plugins/basic_ctcp.rb', line 33

def reply_to_ctcp?(command)
  commands = config[:commands]
  commands.nil? || commands.include?(command)
end