Sha256: 8a130c3965d9fb8d669e60e9d9f4067ede62f6bc8b7044230b0109452663f375
Contents?: true
Size: 913 Bytes
Versions: 17
Compression:
Stored size: 913 Bytes
Contents
module Lita module Handlers # Provides information on Lita users. # @since 4.1.0 class Users extend Lita::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 [Lita::Response] The response object. # @return [void] def find(response) user = Lita::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
17 entries across 17 versions & 1 rubygems