discord: add /tagme command.

This commit is contained in:
evazion
2021-03-19 04:44:22 -05:00
parent cebfe3308e
commit 1a7a108d47
8 changed files with 231 additions and 14 deletions

View File

@@ -260,6 +260,10 @@ class Tag < ApplicationRecord
where("regexp_replace(tags.name, ?, '\\1', 'g') LIKE ?", ABBREVIATION_REGEXP.source, abbrev.to_escaped_for_sql_like)
end
def find_by_name_or_alias(name)
find_by_name(TagAlias.to_aliased(normalize_name(name)))
end
def find_by_abbreviation(abbrev)
abbreviation_matches(abbrev.escape_wildcards).order(post_count: :desc).first
end