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:
63
Addons/Admin/auto-chat.lua
Normal file
63
Addons/Admin/auto-chat.lua
Normal file
@@ -0,0 +1,63 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- white spaces removed and made into lower
|
||||
-- these messages are sent only to the player
|
||||
local auto_chat = '[Chat Bot]: '
|
||||
local messages = {
|
||||
['discord']={'chat-bot.discord'},
|
||||
['expgaming']={'chat-bot.website'},
|
||||
['website']={'chat-bot.website'},
|
||||
['command']={'chat-bot.custom-commands'},
|
||||
['commands']={'chat-bot.custom-commands'},
|
||||
['softmod']={'chat-bot.softmod'},
|
||||
['script']={'chat-bot.softmod'},
|
||||
['afk']=function(_player) local max=_player for _,player in pairs(game.connected_players) do if max.afk_time < player.afk_time then max=player end end {'chat-bot.afk',max.name,tick_to_display_format(max.afk_time)} end
|
||||
}
|
||||
|
||||
-- white spaces removed and made into lower
|
||||
-- these are global chat commands that can be used
|
||||
-- comands start with ! (all messages are also commands)
|
||||
local command_syntax = '!'
|
||||
local names = {'Cooldude2606','arty714','badgamernl'}
|
||||
local commands = {
|
||||
['online']=function(player) return {'chat-bot.players-online',#game.connected_players} end,
|
||||
['playtime']=function(player) return {'chat-bot.map-time',tick_to_display_format(game.tick)} end,
|
||||
['players']=function(player) return {'chat-bot.players',#game.players} end,
|
||||
['dev']={'chat-bot.not-real-dev'},
|
||||
['blame']=function(player) local _names = {unpack(names),player.name} local name = _names[math.random(#_names)] return {'chat-bot.blame',name} end,
|
||||
['readme']={'chat-bot.read-readme'},
|
||||
}
|
||||
|
||||
Event.register(defines.events.on_console_chat,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local player_message = event.message:lower():gsub("%s+", "")
|
||||
local allowed = Ranking.get_rank(player):allowed('global-chat')
|
||||
for to_find,message in pairs(messages) do
|
||||
if player_message:match(command_syntax..to_find) then
|
||||
if allowed then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
game.print{'chat-bot.message',message}
|
||||
else player_return({'chat-bot.rank-error'},nil,player) end
|
||||
elseif player_message:match(to_find) then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
player_return({'chat-bot.message',message},nil,player)
|
||||
end
|
||||
end
|
||||
for to_find,message in pairs(commands) do
|
||||
if player_message:match(command_syntax..to_find) then
|
||||
if allowed then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
game.print{'chat-bot.message',message}
|
||||
else player_return({'chat-bot.rank-error'},nil,player) end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -16,11 +16,11 @@ Event.register(-1,function(event)
|
||||
high_rank= 'Owner',
|
||||
low_rank= 'Regular',
|
||||
low={
|
||||
{'auto-message.join-us'},
|
||||
{'auto-message.discord'},
|
||||
{'auto-message.website'},
|
||||
{'auto-message.custom-commands'},
|
||||
{'auto-message.read-readme'}
|
||||
{'chat-bot.join-us'},
|
||||
{'chat-bot.discord'},
|
||||
{'chat-bot.website'},
|
||||
{'chat-bot.custom-commands'},
|
||||
{'chat-bot.read-readme'}
|
||||
}
|
||||
}
|
||||
}:on_event('timeout',function(self)
|
||||
@@ -28,13 +28,24 @@ Event.register(-1,function(event)
|
||||
if not data.high_rank or not data.low_rank
|
||||
or not data.low then self.reopen = false return end
|
||||
local _high = Ranking.get_rank(data.high_rank)
|
||||
local _low = Ranking.get_rank(data.low_rank)
|
||||
Ranking.print(_high,{'auto-message.players-online',#game.connected_players},nil,true)
|
||||
Ranking.print(_high,{'auto-message.map-time',tick_to_display_format(game.tick)},nil,true)
|
||||
--[[for _,line in pairs(data.low) do
|
||||
game.print{'chat-bot.message',{'chat-bot.players-online',#game.connected_players}}
|
||||
game.print{'chat-bot.message',{'chat-bot.map-time',tick_to_display_format(game.tick)}}
|
||||
--[[local _low = Ranking.get_rank(data.low_rank)
|
||||
Ranking.print(_high,{'chat-bot.players-online',#game.connected_players},nil,true)
|
||||
Ranking.print(_high,{'chat-bot.map-time',tick_to_display_format(game.tick)},nil,true)
|
||||
for _,line in pairs(data.low) do
|
||||
Ranking.print(_low,line,nil,true)
|
||||
end]]
|
||||
self.reopen = true
|
||||
end):on_event(defines.events.on_player_joined_game,function(self,event)
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local data = self.data
|
||||
if not data.high_rank or not data.low_rank
|
||||
or not data.low then self.reopen = false return end
|
||||
for _,message in pairs(data.low) do
|
||||
player_return({'chat-bot.message',message},nil,player)
|
||||
end
|
||||
end):on_event('error',function(self,err)
|
||||
discord_emit{
|
||||
title='Auto Message Error',
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
[auto-message]
|
||||
players-online=Es sind __1__ Spieler online.
|
||||
map-time=Dieses Spiel is seit __1__ am laufen.
|
||||
line-8=Schreibe /help <command> für mehr Informationen.
|
||||
join-us=Folge uns auf:
|
||||
discord=Discord: https://discord.me/explosivegaming
|
||||
website=Webseite: explosivegaming.nl
|
||||
custom-commands=Wir benutzen eigene Befehle wie /tag und /report
|
||||
read-readme=Stelle sicher, dass du das Liesmich gelesen hast (Fragezeichen oben Links)
|
||||
@@ -1,4 +1,6 @@
|
||||
[auto-message]
|
||||
[chat-bot]
|
||||
name=[Chat Bot]
|
||||
rank-error=You cant use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Type /help <command> for more info
|
||||
16
locale/en/chat-bot.cfg
Normal file
16
locale/en/chat-bot.cfg
Normal file
@@ -0,0 +1,16 @@
|
||||
[chat-bot]
|
||||
message=[Chat Bot]: __1__
|
||||
rank-error=You cant use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
player=There have been __1__ players on this map
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Type /help <command> for more info
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.me/explosivegaming
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report, see readme/commands for more info.
|
||||
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)
|
||||
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 in the top left.
|
||||
blame=Blame __1__ for what just happend!
|
||||
afk=Your afk? Look at __1__ they have been afk for: __2__
|
||||
@@ -1,9 +0,0 @@
|
||||
[auto-message]
|
||||
players-online=There are __1__ players online
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Do /help <command> for more info
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.me/explosivegaming
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands such as /tag and /report
|
||||
read-readme=Make sure you have read the readme (top left question mark)
|
||||
11
locale/fr/chat-bot.cfg
Normal file
11
locale/fr/chat-bot.cfg
Normal file
@@ -0,0 +1,11 @@
|
||||
[chat-bot]
|
||||
name=[Chat Bot]
|
||||
rank-error=You cant use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Type /help <command> for more info
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.me/explosivegaming
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report
|
||||
read-readme=Make sure you have read the ReadMe (can be found through the question mark on the top left)
|
||||
@@ -1,9 +0,0 @@
|
||||
[auto-message]
|
||||
players-online=Er zijn __1__ speler(s) online
|
||||
map-time=Deze map is actief voor __1__
|
||||
line-8=Typ /help (command) voor meer informatie
|
||||
join-us=Sluit je aan op onze Discord:
|
||||
discord=Discord: https://discord.me/explosivegaming
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=Wij gebruiken custom commands zoals /tag en /report
|
||||
read-readme=Zorg er voor dat je de readme hebt gelezen (te vinden in de vraagteken linksboven)
|
||||
11
locale/nl/chat-bot.cfg
Normal file
11
locale/nl/chat-bot.cfg
Normal file
@@ -0,0 +1,11 @@
|
||||
[chat-bot]
|
||||
name=[Chat Bot]
|
||||
rank-error=You cant use global chat commands
|
||||
players-online=There are __1__ players online
|
||||
map-time=This map has been on for __1__
|
||||
line-8=Type /help <command> for more info
|
||||
join-us=Please join us on:
|
||||
discord=Discord: https://discord.me/explosivegaming
|
||||
website=Website: explosivegaming.nl
|
||||
custom-commands=We use custom commands, such as /tag and /report
|
||||
read-readme=Make sure you have read the ReadMe (can be found through the question mark on the top left)
|
||||
Reference in New Issue
Block a user