Class: Robut::PM
Instance Attribute Summary
Attributes inherited from Presence
Instance Method Summary collapse
-
#initialize(connection, rooms) ⇒ PM
constructor
A new instance of PM.
- #reply(message, to) ⇒ Object
Methods inherited from Presence
Constructor Details
#initialize(connection, rooms) ⇒ PM
Returns a new instance of PM.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/robut/pm.rb', line 3 def initialize(connection, rooms) # Add the callback from direct messages. Turns out the # on_private_message callback doesn't do what it sounds like, so I # have to go a little deeper into xmpp4r to get this working. self.connection = connection connection.client.(200, self) do || from_room = rooms.any? {|room| room.muc.from_room?(.from)} if !from_room && .type == :chat && .body time = Time.now # TODO: get real timestamp? Doesn't seem like # jabber gives it to us sender_jid = .from plugins = Robut::Plugin.plugins.map { |p| p.new(self, sender_jid) } (plugins, time, connection.roster[sender_jid].iname, .body) true else false end end end |
Instance Method Details
#reply(message, to) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/robut/pm.rb', line 23 def reply(, to) unless to.kind_of?(Jabber::JID) to = find_jid_by_name(to) end msg = Jabber::Message.new(to, ) msg.type = :chat connection.client.send(msg) end |