mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 12:16:37 +09:00
Fixed Chat Reply
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
--- Adds auto replies to chat messages; aswell as chat commands
|
||||
--- Adds auto replies to chat messages; as well as chat commands
|
||||
-- @addon Chat-Reply
|
||||
|
||||
local Event = require 'utils.event' --- @dep utils.event
|
||||
local Game = require 'utils.game' --- @dep utils.game
|
||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||
local config = require 'config.chat_reply' --- @dep config.chat_reply
|
||||
|
||||
@@ -18,16 +17,15 @@ Event.add(defines.events.on_console_chat, function(event)
|
||||
local prefix = config.command_prefix
|
||||
for key_word, reply in pairs(config.messages) do
|
||||
if message:find(key_word) then
|
||||
local is_command = message:find(prefix..key_word)
|
||||
if type(reply) == 'function' then
|
||||
reply = reply(player)
|
||||
reply = reply(player, is_command)
|
||||
end
|
||||
|
||||
if message:find(prefix..key_word) then
|
||||
if allowed then
|
||||
game.print{'chat-bot.reply', reply}
|
||||
else
|
||||
player.print{'chat-bot.disallow'}
|
||||
end
|
||||
if is_command and allowed then
|
||||
game.print{'chat-bot.reply', reply}
|
||||
elseif is_command then
|
||||
player.print{'chat-bot.disallow'}
|
||||
elseif not allowed then
|
||||
player.print{'chat-bot.reply', reply}
|
||||
end
|
||||
@@ -39,7 +37,7 @@ Event.add(defines.events.on_console_chat, function(event)
|
||||
for key_word, reply in pairs(config.commands) do
|
||||
if message:find(prefix..key_word) then
|
||||
if type(reply) == 'function' then
|
||||
reply = reply(player)
|
||||
reply = reply(player, true)
|
||||
|
||||
if reply then
|
||||
game.print{'chat-bot.reply', reply}
|
||||
|
||||
Reference in New Issue
Block a user