Sha256: 69073d12b382b8f87e2a8b1887b62b0ac2749c0eb7b551cfa4b15684a843402b
Contents?: true
Size: 926 Bytes
Versions: 4
Compression:
Stored size: 926 Bytes
Contents
# frozen_string_literal: true module Lita module Handlers # Provides information on Lita users. # @since 4.1.0 class Users extend Handler::ChatRouter route(/^users\s+find\s+(.+)/i, :find, command: true, help: { t("help.find_key") => t("help.find_value") }) # Outputs the name, ID, and mention name of a user matching the search query. # @param response [Response] The response object. # @return [void] def find(response) user = User.fuzzy_find(response.args[1]) if user response.reply(formatted_user(user)) else response.reply(t("find_empty_state")) end end private # Extract and label the relevant user information. def formatted_user(user) "#{user.name} (ID: #{user.id}, Mention name: #{user.mention_name})" end end Lita.register_handler(Users) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rita-5.0.0.alpha.4 | lib/lita/handlers/users.rb |
rita-5.0.0.alpha.3 | lib/lita/handlers/users.rb |
rita-5.0.0.alpha.2 | lib/lita/handlers/users.rb |
rita-5.0.0.alpha.1 | lib/lita/handlers/users.rb |