Class: Hipbot::Adapters::XMPP

Inherits:
Object
  • Object
show all
Includes:
Hipbot::Adaptable
Defined in:
lib/hipbot/adapters/xmpp.rb,
lib/hipbot/adapters/xmpp/client.rb

Direct Known Subclasses

Hipchat, Slack

Defined Under Namespace

Classes: Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject

Returns the value of attribute client.



10
11
12
# File 'lib/hipbot/adapters/xmpp.rb', line 10

def client
  @client
end

Instance Method Details

#invite_to_room(room, users) ⇒ Object



20
21
22
# File 'lib/hipbot/adapters/xmpp.rb', line 20

def invite_to_room(room, users)
  client.invite(user_ids(users), room.id)
end

#join_room(room) ⇒ Object



44
45
46
# File 'lib/hipbot/adapters/xmpp.rb', line 44

def join_room(room)
  client.join(room.id)
end

#kick_from_room(room, users) ⇒ Object



24
25
26
# File 'lib/hipbot/adapters/xmpp.rb', line 24

def kick_from_room(room, users)
  client.kick(user_ids(users), room.id)
end

#leave_room(room, reason = '') ⇒ Object



48
49
50
# File 'lib/hipbot/adapters/xmpp.rb', line 48

def leave_room(room, reason = '')
  client.exit(room.id, reason)
end

#restart!Object



16
17
18
# File 'lib/hipbot/adapters/xmpp.rb', line 16

def restart!
  start!
end

#send_to_room(room, message) ⇒ Object



28
29
30
# File 'lib/hipbot/adapters/xmpp.rb', line 28

def send_to_room(room, message)
  client.send_message(:groupchat, room.id, message)
end

#send_to_user(user, message) ⇒ Object



32
33
34
# File 'lib/hipbot/adapters/xmpp.rb', line 32

def send_to_user(user, message)
  client.send_message(:chat, user.id, message)
end

#set_presence(status, type) ⇒ Object



40
41
42
# File 'lib/hipbot/adapters/xmpp.rb', line 40

def set_presence(status, type)
  client.set_presence(status, type)
end

#set_topic(room, topic) ⇒ Object



36
37
38
# File 'lib/hipbot/adapters/xmpp.rb', line 36

def set_topic(room, topic)
  client.send_message(:groupchat, room.id, nil, topic)
end

#start!Object



12
13
14
# File 'lib/hipbot/adapters/xmpp.rb', line 12

def start!
  self.client = self.class::Client.new.client
end