Class: Chatrix::Components::Admin
- Inherits:
-
Object
- Object
- Chatrix::Components::Admin
- Defined in:
- lib/chatrix/components/admin.rb
Overview
Provides administrative actions for a room.
Instance Method Summary collapse
-
#ban(user, reason) ⇒ Boolean
Bans a user from the room.
-
#initialize(room, matrix) ⇒ Admin
constructor
Initializes a new Admin instance.
-
#join ⇒ Object
Joins the room.
-
#kick(user, reason) ⇒ Boolean
Kicks a user from the room.
-
#leave ⇒ Object
Leaves the room.
-
#unban(user) ⇒ Boolean
Unbans a user from the room.
Constructor Details
#initialize(room, matrix) ⇒ Admin
Initializes a new Admin instance.
14 15 16 17 |
# File 'lib/chatrix/components/admin.rb', line 14 def initialize(room, matrix) @room = room @matrix = matrix end |
Instance Method Details
#ban(user, reason) ⇒ Boolean
Bans a user from the room.
47 48 49 |
# File 'lib/chatrix/components/admin.rb', line 47 def ban(user, reason) @matrix.rooms.actions.ban @room.id, user, reason end |
#join ⇒ Object
Joins the room. Can only be used on public rooms or if the user has been invited.
21 22 23 |
# File 'lib/chatrix/components/admin.rb', line 21 def join @matrix.rooms.actions.join @room.id end |
#kick(user, reason) ⇒ Boolean
Kicks a user from the room.
37 38 39 |
# File 'lib/chatrix/components/admin.rb', line 37 def kick(user, reason) @matrix.rooms.actions.kick @room.id, user, reason end |
#leave ⇒ Object
Leaves the room. If the user is currently invited to the room, leaving the room is the same as rejecting the invite.
27 28 29 |
# File 'lib/chatrix/components/admin.rb', line 27 def leave @matrix.rooms.actions.leave @room.id end |
#unban(user) ⇒ Boolean
Unbans a user from the room.
56 57 58 |
# File 'lib/chatrix/components/admin.rb', line 56 def unban(user) @matrix.rooms.actions.unban @room.id, user end |