mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-02-07 13:31:54 +02:00
Made mentions case insensitive
This commit is contained in:
parent
5c5c59c396
commit
ae46cc447b
@ -105,14 +105,13 @@ local function hodor(event)
|
|||||||
local not_found = 0
|
local not_found = 0
|
||||||
local cannot_mention = {}
|
local cannot_mention = {}
|
||||||
for word in event.message:gmatch('%S+') do
|
for word in event.message:gmatch('%S+') do
|
||||||
local lower_word = word:lower()
|
local word = word:lower()
|
||||||
local trimmed_word = string.sub(word, 0, string.len(word)-1)
|
local trimmed_word = string.sub(word, 0, string.len(word)-1)
|
||||||
local lower_trimmed_word = string.sub(lower_word, 0, string.len(lower_word)-1)
|
|
||||||
local first_char = string.sub(word, 0, 1)
|
local first_char = string.sub(word, 0, 1)
|
||||||
local last_char = string.sub(word, string.len(word))
|
local last_char = string.sub(word, string.len(word))
|
||||||
local success = false
|
local success = false
|
||||||
local admin_call = false
|
local admin_call = false
|
||||||
if lower_word == 'admin' or lower_word == 'moderator' or lower_trimmed_word == 'admin' or lower_trimmed_word == 'moderator' then
|
if word == 'admin' or word == 'moderator' or trimmed_word == 'admin' or trimmed_word == 'moderator' then
|
||||||
admin_call = true
|
admin_call = true
|
||||||
elseif (first_char ~= '#' and last_char ~= '#') and (first_char ~= '@' and last_char ~= '@') then
|
elseif (first_char ~= '#' and last_char ~= '#') and (first_char ~= '@' and last_char ~= '@') then
|
||||||
success = true
|
success = true
|
||||||
@ -123,13 +122,13 @@ local function hodor(event)
|
|||||||
local word_back_trim = trimmed_word
|
local word_back_trim = trimmed_word
|
||||||
local word_front_back_trim = string.sub(word_front_trim, 0, string.len(word_front_trim)-1)
|
local word_front_back_trim = string.sub(word_front_trim, 0, string.len(word_front_trim)-1)
|
||||||
local word_back_double_trim = string.sub(word_back_trim, 0, string.len(word_back_trim)-1)
|
local word_back_double_trim = string.sub(word_back_trim, 0, string.len(word_back_trim)-1)
|
||||||
word = (lower_trimmed_word == 'admin' or lower_trimmed_word == 'moderator') and trimmed_word or word
|
word = (trimmed_word == 'admin' or trimmed_word == 'moderator') and trimmed_word or word
|
||||||
if admin_call and p.admin then
|
if admin_call and p.admin then
|
||||||
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned '..word..'!', {r = 1, g = 1, b = 0, a = 1})
|
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned '..word..'!', {r = 1, g = 1, b = 0, a = 1})
|
||||||
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
|
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
|
||||||
success = true
|
success = true
|
||||||
end
|
end
|
||||||
if not admin_call and (p.name == word_front_trim or p.name == word_back_trim or p.name == word_back_double_trim or p.name == word_front_back_trim) then
|
if not admin_call and (p.name:lower() == word_front_trim or p.name:lower() == word_back_trim or p.name:lower() == word_back_double_trim or p.name:lower() == word_front_back_trim) then
|
||||||
if p.name == player.name then
|
if p.name == player.name then
|
||||||
if _DEBUG then
|
if _DEBUG then
|
||||||
player.print(prefix..'Can\'t mention yourself!', {r = 1, g = 0, b = 0, a = 1})
|
player.print(prefix..'Can\'t mention yourself!', {r = 1, g = 0, b = 0, a = 1})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user