mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Added chat bot
This commit is contained in:
@@ -35,6 +35,7 @@ return {
|
||||
'modules.addons.pollution-grading',
|
||||
'modules.addons.random-player-colours',
|
||||
'modules.addons.discord-alerts',
|
||||
'modules.addons.chat-reply',
|
||||
-- GUI
|
||||
'modules.gui.rocket-info',
|
||||
'modules.gui.science-info',
|
||||
|
||||
66
config/chat_reply.lua
Normal file
66
config/chat_reply.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
--- This file defines the different triggers for the chat bot
|
||||
local format_time = ext_require('expcore.common','format_time')
|
||||
return {
|
||||
allow_command_prefix_for_messages = true, -- when true any message trigger will print to all player when prefixed
|
||||
messages = { -- will trigger when ever the word is said
|
||||
['discord']={'info.discord'},
|
||||
['expgaming']={'info.website'},
|
||||
['website']={'info.website'},
|
||||
['wiki']={'info.wiki'},
|
||||
['status']={'info.status'},
|
||||
['github']={'info.github'},
|
||||
['command']={'info.custom-commands'},
|
||||
['commands']={'info.custom-commands'},
|
||||
['softmod']={'info.softmod'},
|
||||
['script']={'info.softmod'},
|
||||
['loop']={'chat-bot.loops'},
|
||||
['loops']={'chat-bot.loops'},
|
||||
['rhd']={'chat-bot.lhd'},
|
||||
['lhd']={'chat-bot.lhd'},
|
||||
['roundabout']={'chat-bot.loops'},
|
||||
['roundabouts']={'chat-bot.loops'},
|
||||
['redmew']={'chat-bot.redmew'},
|
||||
['afk']=function(player)
|
||||
local max=player
|
||||
for _,next_player in pairs(game.connected_players) do
|
||||
if max.afk_time < next_player.afk_time then
|
||||
max=next_player
|
||||
end
|
||||
end
|
||||
return {'chat-bot.afk',max.name,format_time(max.afk_time,{minutes=true,seconds=true,long=true})}
|
||||
end,
|
||||
['players']=function()
|
||||
return {'chat-bot.players',#game.players}
|
||||
end,
|
||||
['online']=function()
|
||||
return {'chat-bot.players-online',#game.connected_players}
|
||||
end,
|
||||
['time']=function()
|
||||
return {'chat-bot.map-time',format_time(game.tick,{days=true,hours=true,minutes=true,seconds=true,long=true})}
|
||||
end,
|
||||
},
|
||||
command_admin_only = false, -- when true will only allow chat commands for admins
|
||||
command_permission = 'command/chat-bot', -- the permision used to allow command prefixs
|
||||
command_prefix = '!', -- prefix used for commands below and to print to all players (if enabled above)
|
||||
commands = { -- will trigger only when command prefix is given
|
||||
['dev']={'chat-bot.not-real-dev'},
|
||||
['blame']=function(player)
|
||||
local names = {'Cooldude2606','arty714','badgamernl',player.name}
|
||||
for _,next_player in pairs(game.connected_players) do
|
||||
names[#names + 1] = next_player.name
|
||||
end
|
||||
return {'chat-bot.blame',table.get_random_dictionary_entry(names)}
|
||||
end,
|
||||
['magic']={'chat-bot.magic'},
|
||||
['aids']={'chat-bot.aids'},
|
||||
['riot']={'chat-bot.riot'},
|
||||
['lenny']={'chat-bot.lenny'},
|
||||
['hodor']=function()
|
||||
local options = {'?','.','!','!!!'}
|
||||
return {'chat-bot.hodor',table.get_random_dictionary_entry(options)}
|
||||
end,
|
||||
['evolution']=function()
|
||||
return {'chat-bot.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)}
|
||||
end,
|
||||
}
|
||||
}
|
||||
@@ -6,17 +6,17 @@ return {
|
||||
},
|
||||
messages={ -- the messages that each one will say, must be same name as its location
|
||||
['Spawn']={
|
||||
{'info.website-message'},
|
||||
{'info.website'},
|
||||
{'info.read-readme'},
|
||||
{'info.discord-message'},
|
||||
{'info.discord'},
|
||||
{'info.softmod'},
|
||||
{'info.wiki-message'},
|
||||
{'info.wiki'},
|
||||
{'info.redmew'},
|
||||
{'info.feedback-message'},
|
||||
{'info.feedback'},
|
||||
{'info.custom-commands'},
|
||||
{'info.status-message'},
|
||||
{'info.status'},
|
||||
{'info.lhd'},
|
||||
{'info.github-message'},
|
||||
{'info.github'},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,7 @@ Roles.new_role('Veteran','Vet')
|
||||
:set_custom_color{r=140,g=120,b=200}
|
||||
:set_parent('Member')
|
||||
:allow{
|
||||
'command/chat-bot',
|
||||
}
|
||||
:set_auto_promote_condition(function(player)
|
||||
if player.online_time > 10*216000 then
|
||||
|
||||
@@ -11,7 +11,7 @@ return {
|
||||
{'warnings.received',{'warnings.pre-pre-ban'}},
|
||||
{'warnings.received',{'warnings.pre-ban'}},
|
||||
function(player,by_player_name,number_of_warnings)
|
||||
game.ban_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.ban',{'info.website-link'}}})
|
||||
game.ban_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.ban',{'links.website'}}})
|
||||
end
|
||||
},
|
||||
temp_warning_cool_down=30, -- time for a temp warning (given by script) to be removed (in minutes)
|
||||
|
||||
@@ -6,21 +6,23 @@ ping=You have been mentioned in chat by __1__.
|
||||
player-health=__1__
|
||||
player-damage=__1__
|
||||
|
||||
[links]
|
||||
discord=https://discord.explosivegaming.nl
|
||||
website=https://www.explosivegaming.nl
|
||||
wiki=https://wiki.explosivegaming.nl/
|
||||
feedback=https://exp.fider.io/
|
||||
status=https://status.explosivegaming.nl
|
||||
github=https://github.com/explosivegaming/scenario
|
||||
|
||||
[info]
|
||||
players-online=There are __1__ players online
|
||||
total-map-time=This map has been on for __1__
|
||||
discord-link=https://discord.explosivegaming.nl
|
||||
discord-message=Join use on our discord at: https://discord.explosivegaming.nl
|
||||
website-link=https://www.explosivegaming.nl
|
||||
website-message=Please vist our website at: https://www.explosivegaming.nl
|
||||
wiki-link=https://wiki.explosivegaming.nl/
|
||||
wiki-message=You can get more information about us and the custom scenario from our wiki: https://wiki.explosivegaming.nl/
|
||||
feedback-link=https://exp.fider.io/
|
||||
feedback-message=Do you have feedback? leave it at https://exp.fider.io/
|
||||
status-link=https://status.explosivegaming.nl
|
||||
status-message=Want to check if out servers are down, vist: https://status.explosivegaming.nl
|
||||
github-link=https://github.com/explosivegaming/scenario
|
||||
github-message=Want to help improve our server with some extra features? Help us at: https://github.com/explosivegaming/scenario
|
||||
discord=Join use on our discord at: https://discord.explosivegaming.nl
|
||||
website=Please vist our website at: https://www.explosivegaming.nl
|
||||
wiki=You can get more information about us and the custom scenario from our wiki: https://wiki.explosivegaming.nl/
|
||||
feedback=Do you have feedback? leave it at https://exp.fider.io/
|
||||
status=Want to check if out servers are down, vist: https://status.explosivegaming.nl
|
||||
github=Want to help improve our server with some extra features? Help us at: https://github.com/explosivegaming/scenario
|
||||
custom-commands=We use custom commands, such as /tag and /me, use /chelp for more info.
|
||||
read-readme=Make sure you have read the Readme (It can be found through the question mark on the top left)
|
||||
softmod=We run a softmod on our servers. A softmod is a custom scenario that runs on this server, example is the player list.
|
||||
@@ -36,4 +38,22 @@ pre-ban=This your LAST warning before you are BANNED! successful ban appeals are
|
||||
ban=You were banned for having too many warnings; Vist __1__ to request a ban appeal.
|
||||
script-warning=You are reciving script warnings; if you recive too many you will recive a permiment warning (__1__/__2__)
|
||||
script-wrning-removed=A script warning has expired (__1__/__2__)
|
||||
script-warning-limit=__1__ has recived a permiment warning from the script.
|
||||
script-warning-limit=__1__ has recived a permiment warning from the script.
|
||||
|
||||
[chat-bot]
|
||||
reply=[Chat Bot] __1__
|
||||
disallow=You cant use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
players=There have been __1__ players on this map
|
||||
map-time=This map has been on for __1__
|
||||
not-real-dev=Cooldude2606 is a dev for this server and makes the softmod (look top left) and is not a factorio dev.
|
||||
softmod=A softmod is a custom scenario that runs on this server, example is the player list.
|
||||
blame=Blame __1__ for what just happend!
|
||||
afk=Your afk? Look at __1__, that player has been afk for: __2__
|
||||
current-evolution=Current evolution factor is __1__
|
||||
magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
|
||||
aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
|
||||
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ ‹ ‹\(´ω` )/››‹‹\ ( ´)/››‹‹\ ( ´ω`)/›› (rest of server)
|
||||
loops=NO LOOPS; LOOPS ARE BAD; JUST NO LOOPS!!!!!; IF YOU MAKE A LOOP.... IT WILL NOT END WELL!!!!!!!
|
||||
lenny=( ͡° ͜ʖ ͡°)
|
||||
hodor=Hodor
|
||||
51
modules/addons/chat-reply.lua
Normal file
51
modules/addons/chat-reply.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
local Event = require 'utils.event'
|
||||
local Game = require 'utils.game'
|
||||
local Roles = require 'expcore.roles'
|
||||
local config = require 'config.chat_reply'
|
||||
|
||||
Event.add(defines.events.on_console_chat,function(event)
|
||||
local player_index = event.player_index
|
||||
if not player_index or player_index < 1 then return end
|
||||
local player = Game.get_player_by_index(player_index)
|
||||
local message = event.message:lower():gsub("%s+", "")
|
||||
local allowed = true
|
||||
if config.command_admin_only and not player.admin then allowed = false end
|
||||
if config.command_permission and not Roles.player_allowed(player,config.command_permission) then allowed = false end
|
||||
|
||||
local prefix = config.command_prefix
|
||||
for key_word,reply in pairs(config.messages) do
|
||||
if message:find(key_word) then
|
||||
if type(reply) == 'function' then
|
||||
reply = reply(player)
|
||||
end
|
||||
|
||||
if message:find(prefix..key_word) then
|
||||
if allowed then
|
||||
game.print{'chat-bot.reply',reply}
|
||||
else
|
||||
player.print{'chat-bot.disallow'}
|
||||
end
|
||||
else
|
||||
player.print{'chat-bot.reply',reply}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not allowed then return end
|
||||
|
||||
for key_word,reply in pairs(config.commands) do
|
||||
if message:find(prefix..key_word) then
|
||||
if type(reply) == 'function' then
|
||||
reply = reply(player)
|
||||
|
||||
if reply then
|
||||
game.print{'chat-bot.reply',reply}
|
||||
end
|
||||
|
||||
else
|
||||
game.print{'chat-bot.reply',reply}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user