Sha256: a13b4bf84fbb43d3c66dac5bf39e1fad91da37d3e0812e19a83db0978241f62b
Contents?: true
Size: 895 Bytes
Versions: 1
Compression:
Stored size: 895 Bytes
Contents
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-default-handlers-0.1.0 | lib/lita/handlers/users.rb |