Class: Gossip::JabberCrony
- Inherits:
-
Crony
- Object
- Crony
- Gossip::JabberCrony
show all
- Includes:
- Jabber
- Defined in:
- lib/gossip/cronies/jabber.rb
Instance Attribute Summary
Attributes inherited from Crony
#is_bff_by_default, #user_choices
Instance Method Summary
collapse
Methods inherited from Crony
#add_bff_choice, #checked, #df, #initialize, #is_bff?, #is_bff_by_default?, #postprocess_user_choices
Constructor Details
This class inherits a constructor from Gossip::Crony
Instance Method Details
#add_configuration_choices(builder) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/gossip/cronies/jabber.rb', line 22
def add_configuration_choices(builder)
builder.add_choice(:jabber_to,
:default => checked(:default_to),
:type => [:string]) { | command_line |
command_line.uses_option("--jabber-to RECIPIENTS",
"Recipients of Jabber instant messages.",
"This can be a comma-separated list.",
df(:default_to)
)
}
builder.add_choice(:jabber_account,
:default => checked(:default_account)) { | command_line |
command_line.uses_option("--jabber-account SENDER",
"Your Jabber account.",
"Note that this includes the Jabber server.",
df(:default_account)
)
}
builder.add_choice(:jabber_password,
:default => checked(:default_password)) { | command_line |
command_line.uses_option("--jabber-password PASSWORD",
"Your Jabber password.",
df(:default_password)
)
}
end
|
#command_line_description ⇒ Object
16
17
18
19
20
|
# File 'lib/gossip/cronies/jabber.rb', line 16
def command_line_description
['-j', "--jabber",
"Control IM notification.",
"Defaults to #{is_bff_by_default?}."]
end
|
#hear(scandal, details) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/gossip/cronies/jabber.rb', line 51
def hear(scandal, details)
my_jid = JID.new(@user_choices[:jabber_account])
cl = quiet_client(my_jid)
cl.connect
cl.auth(@user_choices[:jabber_password])
details = [scandal, details].join("\n")
@user_choices[:jabber_to].each do | recipient |
m = Message::new(recipient, details).
set_type(:normal).set_id('1').set_subject(scandal)
cl.send(m)
end
cl.close
end
|
#name ⇒ Object
13
|
# File 'lib/gossip/cronies/jabber.rb', line 13
def name; "jabber"; end
|
#quiet_client(my_jid) ⇒ Object
Current XMPP4R (0.3.1) prints warning message that’s not important.
66
67
68
69
70
71
72
73
|
# File 'lib/gossip/cronies/jabber.rb', line 66
def quiet_client(my_jid)
cl = nil
msg = capturing_stderr do
cl = Client.new(my_jid, false)
end
$stderr.puts msg unless msg =~ /Non-threaded mode is currently broken/
cl
end
|
#symbol ⇒ Object
14
|
# File 'lib/gossip/cronies/jabber.rb', line 14
def symbol; :jabber; end
|