Sha256: 62bf5c04b99dc11d7210d2c1d836ce42259853a7fadde3ebe4a9f18033cc243d

Contents?: true

Size: 955 Bytes

Versions: 1

Compression:

Stored size: 955 Bytes

Contents

module Lita
  # A namespace to hold all subclasses of {Handler}.
  module Handlers
    # Allows administrators to make Lita join and part from rooms.
    # @since 3.0.0
    class Room
      extend Handler::ChatRouter

      route(/^join\s+(.+)$/i, :join, command: true, restrict_to: :admins, help: {
        t("help.join_key") => t("help.join_value")
      })

      route(/^part\s+(.+)$/i, :part, command: true, restrict_to: :admins, help: {
        t("help.part_key") => t("help.part_value")
      })

      # Joins the room with the specified ID.
      # @param response [Response] The response object.
      # @return [void]
      def join(response)
        robot.join(response.args[0])
      end

      # Parts from the room with the specified ID.
      # @param response [Response] The response object.
      # @return [void]
      def part(response)
        robot.part(response.args[0])
      end
    end

    Lita.register_handler(Room)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-default-handlers-0.1.0 lib/lita/handlers/room.rb