Class: Lita::Handlers::Authorization

Inherits:
Object
  • Object
show all
Extended by:
Handler::ChatRouter
Defined in:
lib/lita/handlers/authorization.rb

Overview

Provides a chat interface for administering authorization groups.

Instance Method Summary collapse

Instance Method Details

#add(response) ⇒ void

This method returns an undefined value.

Adds a user to an authorization group.

Parameters:

  • response (Response)

    The response object.



29
30
31
# File 'lib/lita/handlers/authorization.rb', line 29

def add(response)
  toggle_membership(response, :add_user_to_group, "user_added", "user_already_in")
end

#list(response) ⇒ void

This method returns an undefined value.

Lists all authorization groups (or only the specified group) and the names of their members.

Parameters:

  • response (Response)

    The response object.



44
45
46
47
48
49
50
51
52
# File 'lib/lita/handlers/authorization.rb', line 44

def list(response)
  requested_group = response.args[1]
  output = get_groups_list(response.args[1])
  if output.empty?
    response.reply(empty_state_for_list(requested_group))
  else
    response.reply(output.join("\n"))
  end
end

#remove(response) ⇒ void

This method returns an undefined value.

Removes a user from an authorization group.

Parameters:

  • response (Response)

    The response object.



36
37
38
# File 'lib/lita/handlers/authorization.rb', line 36

def remove(response)
  toggle_membership(response, :remove_user_from_group, "user_removed", "user_not_in")
end