Class: Weechat::IRC::CTCP

Inherits:
Modifier show all
Defined in:
lib/weechat/irc/ctcp.rb

Instance Attribute Summary

Attributes inherited from Modifier

#modifier

Attributes inherited from Hook

#callback, #id

Attributes included from Pointer

#ptr

Instance Method Summary (collapse)

Methods inherited from Modifier

call, #exec, inherited

Methods inherited from Hook

all, #call, compute_free_id, find_by_id, #hooked?, inherited, init, register, unhook, #unhook, unhook_all, unregister

Methods included from Pointer

#==, #hash, included, #inspect, #to_s

Constructor Details

- (CTCP) initialize(command, &callback)



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/weechat/irc/ctcp.rb', line 4

def initialize(command, &callback)
  super("irc_in_privmsg") do |server, line|
    ret = line
    m = Weechat::IRC::Message.new(line.message)

    if m.ctcp? && (ctcp = m.to_ctcp).ctcp_command == command
       callback.call(server, ctcp)
       ret = nil
    end

    ret
  end
end