Fixed Chat Reply

This commit is contained in:
Cooldude2606
2020-08-14 02:17:51 +01:00
parent e0eba193a4
commit 97f2d9b967
7 changed files with 81 additions and 86 deletions

View File

@@ -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}