Sha256: 4ac2afafb14844e431d802158bfb20a3bc7c9942975c55a2b89463453dd14d87

Contents?: true

Size: 986 Bytes

Versions: 4

Compression:

Stored size: 986 Bytes

Contents

# frozen_string_literal: true

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

4 entries across 4 versions & 1 rubygems

Version Path
rita-5.0.0.alpha.4 lib/lita/handlers/room.rb
rita-5.0.0.alpha.3 lib/lita/handlers/room.rb
rita-5.0.0.alpha.2 lib/lita/handlers/room.rb
rita-5.0.0.alpha.1 lib/lita/handlers/room.rb