Refactor of commands

This commit is contained in:
Cooldude2606
2019-03-01 20:24:23 +00:00
parent e547f76d6f
commit 62dcfe8694
288 changed files with 5364 additions and 1067 deletions

View File

@@ -0,0 +1,166 @@
--- Sends messages in chat in response to other messages
-- @module ExpGamingBot.autoChat
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Game = require('FactorioStdLib.Game')
local Server = require('ExpGamingCore.Server')
local Role -- ExpGamingCore.Role@^4.0.0
-- Local Variables
-- lots of these are jokes, but some have uses
-- white spaces removed and made into lower
-- these messages are sent only to the player
local messages = {
['discord']={'ExpGamingBot-autoChat.discord'},
['expgaming']={'ExpGamingBot-autoChat.website'},
['website']={'ExpGamingBot-autoChat.website'},
['command']={'ExpGamingBot-autoChat.custom-commands'},
['commands']={'ExpGamingBot-autoChat.custom-commands'},
['softmod']={'ExpGamingBot-autoChat.softmod'},
['script']={'ExpGamingBot-autoChat.softmod'},
['link']={'ExpGamingBot-autoChat.links'},
['links']={'ExpGamingBot-autoChat.links'},
['loop']={'ExpGamingBot-autoChat.loops'},
['loops']={'ExpGamingBot-autoChat.loops'},
['rhd']={'ExpGamingBot-autoChat.lhd'},
['roundabout']={'ExpGamingBot-autoChat.loops'},
['roundabouts']={'ExpGamingBot-autoChat.loops'},
['redmew']={'ExpGamingBot-autoChat.redmew'},
['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 return {'ExpGamingBot-autoChat.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
-- commands start with ! (all messages are also commands)
local command_syntax = '!'
local commands = {
['online']=function() return {'ExpGamingBot-autoChat.players-online',#game.connected_players} end,
['playtime']=function() return {'ExpGamingBot-autoChat.map-time',tick_to_display_format(game.tick)} end,
['players']=function() return {'ExpGamingBot-autoChat.players',#game.players} end,
['dev']={'ExpGamingBot-autoChat.not-real-dev'},
['blame']=function(player) local names = {'Cooldude2606','arty714','badgamernl',player.name} return {'ExpGamingBot-autoChat.blame',names[math.random(#names)]} end,
['readme']={'ExpGamingBot-autoChat.read-readme'},
['magic']={'ExpGamingBot-autoChat.magic'},
['aids']={'ExpGamingBot-autoChat.aids'},
['riot']={'ExpGamingBot-autoChat.riot'},
['lenny']={'ExpGamingBot-autoChat.lenny'},
['feedback']={'ExpGamingBot-autoChat.feedback'},
['wiki']={'ExpGamingBot-autoChat.wiki'},
['hodor']=function() local options = {'?','.','!','!!!'} return {'ExpGamingBot-autoChat.hodor',options[math.random(#options)]} end,
['evolution']=function() return {'ExpGamingBot-autoChat.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)} end,
--Jokes about food and drink
['whattoeat']={'ExpGamingBot-autoChat.food'},
['makepopcorn']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data=player.name
}:on_event('timeout',function(self)
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-popcorn-2',self.data}} end
end):open() return {'ExpGamingBot-autoChat.get-popcorn-1'} end,
['orderpizza']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
}:on_event('timeout',function(self)
if self.data[2]==0 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.order-pizza-2',self.data[1]}}
elseif self.data[2]==1 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.order-pizza-3',self.data[1]}} self.reopen = false
end
self.data[2]=self.data[2]+1
end):open() return {'ExpGamingBot-autoChat.order-pizza-1'} end,
['passsomesnaps']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
}:on_event('timeout',function(self)
if self.data[2]==0 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-snaps-2',self.data[1]}}
elseif self.data[2]==1 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-snaps-3',self.data[1]}} self.reopen = false
end
self.data[2]=self.data[2]+1
end):open() return {'ExpGamingBot-autoChat.get-snaps-1'} end,
['makecocktail']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
}:on_event('timeout',function(self)
if self.data[2]==0 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-cocktail-2',self.data[1]}}
elseif self.data[2]==1 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-cocktail-3',self.data[1]}} self.reopen = false
end
self.data[2]=self.data[2]+1
end):open() return {'ExpGamingBot-autoChat.get-cocktail-1'} end,
['makecoffee']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data=player.name
}:on_event('timeout',function(self)
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.make-coffee-2',self.data}} end
end):open() return {'ExpGamingBot-autoChat.make-coffee-1'} end,
['orderpizza']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
}:on_event('timeout',function(self)
if self.data[2]==0 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.order-pizza-2',self.data[1]}}
elseif self.data[2]==1 then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.order-pizza-3',self.data[1]}} self.reopen = false
end
self.data[2]=self.data[2] + 1
end):open() return {'ExpGamingBot-autoChat.order-pizza-1'} end,
['maketea']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data=player.name
}:on_event('timeout',function(self)
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.make-tea-2',self.data}} end
end):open() return {'ExpGamingBot-autoChat.make-tea-1'} end,
['popcorn']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data=player.name
}:on_event('timeout',function(self)
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-popcorn-2',self.data}} end
end):open() return {'ExpGamingBot-autoChat.get-popcorn-1'} end,
['meadplease']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data=player.name
}:on_event('timeout',function(self)
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-mead-2',self.data}} end
end):open() return {'ExpGamingBot-autoChat.get-mead-1'} end,
['passabeer']=function(player) Server.new_thread{
timeout=math.floor(180*(math.random()+0.5)),data=player.name
}:on_event('timeout',function(self)
if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-beer-2',self.data}} end
end):open() return {'ExpGamingBot-autoChat.get-beer-1'} end
}
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
end
}
-- Event Handlers Define
Event.add(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 = Role and Role.allowed(player,'global-chat') or player.admin
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{'ExpGamingBot-autoChat.message',message}
else player_return({'ExpGamingBot-autoChat.rank-error'},nil,player) end
elseif player_message:match(to_find) then
if is_type(message,'function') then message=message(player) end
if not allowed then player_return({'ExpGamingBot-autoChat.message',message},nil,player) end
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{'ExpGamingBot-autoChat.message',message}
else player_return({'ExpGamingBot-autoChat.rank-error'},nil,player) end
end
end
end)
-- Module Return
return ThisModule

View File

@@ -0,0 +1,20 @@
[ExpGamingBot-autoChat]
message=[Chat Bot]: __1__
rank-error=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__
line-8=Type /help <command> for more info
join-us=Please join us on:
discord=Discord: https://discord.explosivegaming.nl
website=Website: explosivegaming.nl
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme 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 is the player list.
blame=Blame __1__ for what just happend!
afk=Your afk? Look at __1__ they have been afk for: __2__
links=To see links open the readme and click links.
magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ \(´ω` )/\ (  ´)/\ ( ´ω`)/ (rest of server)

View File

@@ -0,0 +1,48 @@
[ExpGamingBot-autoChat]
message=[Chat Bot]: __1__
rank-error=You can't 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__
line-8=Type /help <command> for more info
join-us=Please join us on:
discord=Discord: https://discord.explosivegaming.nl
website=Website: https://www.explosivegaming.nl
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
read-readme=Make sure you have read the Readme (It 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 is the player list.
redmew=We dont talk about redmew here; they beat us to 1000 members; F
blame=Blame __1__ for what just happend!
afk=Your afk? Look at __1__, that player has been afk for: __2__
links=To see links open the readme and click links.
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=( ͡° ͜ʖ ͡°)
make-tea-1= ☕ Boiling the water... ☕
make-tea-2= ☕ __1__ your tea is done! ☕
order-pizza-1= 🍕 Finding nearest pizza supplier... 🍕
order-pizza-2= 🍕 Figuring out the favourite pizza of __1__ 🍕
order-pizza-3= 🍕 __1__ your pizza is here! 🍕
make-coffee-1= ☕ Boiling the water and grinding the coffee beans... ☕
make-coffee-2= ☕ __1__ we ran out of coffe beans! Have some tea instead. ☕
get-beer-1= 🍺 Pouring A Glass 🍺
get-beer-2= 🍻 Chears Mate 🍻
get-mead-1= Filling the drinking horn
get-mead-2= Skål!
get-snaps-1=Pouring the glasses and finding the correct song book...
get-snaps-2=Singing a song...🎤🎶
get-snaps-3=skål, my friends!
get-cocktail-1= 🍸 Inintiating mind reading unit... 🍸
get-cocktail-2= 🍸 Mixing favourite ingredients of __1__ 🍸
get-cocktail-3=🍸 __1__ your cocktail is done.🍸
lhd=All trains must be LHD!
food=Don't know what to make for dinner? Use a random recipe from the random dinner suggestion generator at http://www.whatthefuckshouldimakefordinner.com/
get-popcorn-1=Heating the oil and waiting for the popping sound...
get-popcorn-2=__1__ your popcorn is finished. Lean backwards and watch the drama unfold.
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/
hodor=Hodor

View File

@@ -0,0 +1,20 @@
[ExpGamingBot-autoChat]
message=[Chat Bot]: __1__
rank-error=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__
line-8=Type /help <command> for more info
join-us=Please join us on:
discord=Discord: https://discord.explosivegaming.nl
website=Website: explosivegaming.nl
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme 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 is the player list.
blame=Blame __1__ for what just happend!
afk=Your afk? Look at __1__ they have been afk for: __2__
links=To see links open the readme and click links.
magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ \(´ω` )/\ (  ´)/\ ( ´ω`)/ (rest of server)

View File

@@ -0,0 +1,20 @@
[ExpGamingBot-autoChat]
message=[Chat Bot]: __1__
rank-error=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__
line-8=Type /help <command> for more info
join-us=Please join us on:
discord=Discord: https://discord.explosivegaming.nl
website=Website: explosivegaming.nl
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme 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 is the player list.
blame=Blame __1__ for what just happend!
afk=Your afk? Look at __1__ they have been afk for: __2__
links=To see links open the readme and click links.
magic=Fear the admin magic (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
aids=≖ ‿ ≖ Fear the aids of a public server ≖ ‿ ≖
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ \(´ω` )/\ (  ´)/\ ( ´ω`)/ (rest of server)

View File

@@ -0,0 +1,25 @@
[ExpGamingBot-autoChat]
message=[Chat Bot]: __1__
rank-error=Du kan inte utföra globala chat-kommandon.
players-online=Det är __1__ spelare online
players=Det har varit __1__ spelare på den här kartan
map-time=Den här kartan har varit igång under __1__
line-8=Type /help <kommando> för mer information
join-us=Var snäll och förena dig med oss:
discord=Discord: https://discord.explosivegaming.nl
website=Website: explosivegaming.nl
custom-commands=Vi använder oss av specialiserade kommandon, som till exempel /tag och /report, se kommandotabben i readme för mer information.
read-readme=Se till att du har läst "Readme" (Finn den genom att klicka på frågetecknet högst upp i vänstra hörnet)
not-real-dev=Cooldude2606 är dev för den här servern och gör mjukmodden ("the softmod") och är inte en factorio dev.
ssoftmod=En mjukmod ("softmod") är ett specialscenario som används på den här servern, exempelvis listan över spelare.
blame=Skyll på __1__ för vad som just hände!
afk=Är du afk (borta från tangentbordet)? Titta på __1__, den spelaren har varit afk under: __2__
links=För att se länkar, öppna readme och klicka "länkar".
magic=Frukta admin-magin (ノ゚∀゚)ノ⌒・*:.。. .。.:*・゜゚・*☆
aids=≖ ‿ ≖Fear the aids of a public server ≖ ‿ ≖
riot=(admins) ┬┴┬┴┤ᵒ_ᵒ)├┬┴┬┴ \(´ω` )/\ (  ´)/\ ( ´ω`)/ (rest of server)
loops=INGA LOOPAR; LOOPAR ÄR DÅLIGT; JUST INGA LOOPAR!!!!!; OM DU GJÖR EN LOOP.... DET KOMMER INTE ATT SLUTA VÄL!!!!!!!
lhd=Alla tåg skall köras med vänstertrafik!
current-evolution=Nuvarande evolutionsfaktor är __1__
wiki=Du kan få mer information om oss och scenariot på vår wiki: https://wiki.explosivegaming.nl/

View File

@@ -0,0 +1,19 @@
{
"name": "ExpGamingBot.autoChat",
"version": "4.0.0",
"description": "Sends messages in chat based on what has been said by other players",
"location": "FSM_ARCHIVE",
"keywords": [
"Chat",
"Bot",
"Jokes",
"Fun"
],
"dependencies": {
"FactorioStdLib.Game": "^0.8.0",
"ExpGamingCore.Server": "^4.0.0",
"ExpGamingCore.Role": "?^4.0.0"
},
"collection": "ExpGamingBot@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,74 @@
--- Prints a message every 15 minutes to chat.
-- @module ExpGamingBot.autoMessage
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Server = require('ExpGamingCore.Server')
local Game = require('FactorioStdLib.Game')
local Role -- ExpGamingCore.Role@4.0.0
local Sync -- ExpGamingCore.Sync@4.0.0
-- Local Variables
-- Module Define
local module_verbose = false
local ThisModule = {
on_init=function()
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end
end,
on_post=function()
--code
end
}
-- Event Handlers Define
script.on_init(function()
Server.new_thread{
name='auto-message',
timeout=54000, -- 3240000 = 15 hours dont make the mistake i did, 54000 is 15 minutes
reopen=true,
data={
high_role= 'Owner',
low_role= 'Regular',
low={
{'ExpGamingBot-autoMessage.join-us'},
{'ExpGamingBot-autoMessage.discord'},
{'ExpGamingBot-autoMessage.website'},
{'ExpGamingBot-autoMessage.custom-commands'},
{'ExpGamingBot-autoMessage.read-readme'}
}
}
}:on_event('timeout',function(self)
local data = self.data
if not data.high_role or not data.low_role
or not data.low then self.reopen = false return end
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.players-online',#game.connected_players}}
game.print{'ExpGamingBot-autoMessage.message',{'ExpGamingBot-autoMessage.map-time',tick_to_display_format(game.tick)}}
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_role or not data.low_role
or not data.low then self.reopen = false return end
if Role and Role.get_highest(player).index <= Role.get(data.low_role).index or player.admin then return end
for _,message in pairs(data.low) do
player_return({'ExpGamingBot-autoMessage.message',message},nil,player)
end
end):on_event('error',function(self,err)
if Sync then Sync.emit_embedded{
title='Auto Message Error',
color=Color.to_hex(defines.textcolor.bg),
description='Auto Message Error - Closed Thread',
Error=err
} end
self.reopen = false
self:close()
end):open()
end)
-- Module Return
return ThisModule

View File

@@ -0,0 +1,9 @@
[ExpGamingBot-autoMessage]
message=[Chat Bot]: __1__
players-online=There are __1__ players online
map-time=This map has been on for __1__
join-us=Please join us on:
discord=Discord: https://discord.explosivegaming.nl
website=Website: explosivegaming.nl
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)

View File

@@ -0,0 +1,9 @@
[ExpGamingBot-autoMessage]
message=[Chat Bot]: __1__
players-online=There are __1__ players online
map-time=This map has been on for __1__
join-us=Please join us on:
discord=Discord: https://discord.explosivegaming.nl
website=Website: https://www.explosivegaming.nl
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
read-readme=Make sure you have read the Readme (It can be found through the question mark on the top left)

View File

@@ -0,0 +1,9 @@
[ExpGamingBot-autoMessage]
message=[Chat Bot]: __1__
players-online=There are __1__ players online
map-time=This map has been on for __1__
join-us=Please join us on:
discord=Discord: https://discord.explosivegaming.nl
website=Website: explosivegaming.nl
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)

View File

@@ -0,0 +1,9 @@
[ExpGamingBot-autoMessage]
message=[Chat Bot]: __1__
players-online=There are __1__ players online
map-time=This map has been on for __1__
join-us=Please join us on:
discord=Discord: https://discord.explosivegaming.nl
website=Website: explosivegaming.nl
custom-commands=We use custom commands, such as /tag and /report, see the commands tab in readme for more info.
read-readme=Make sure you have read the Readme (can be found through the question mark on the top left)

View File

@@ -0,0 +1,10 @@
[ExpGamingBot-autoMessage]
message=[Chat Bot]: __1__
players-online=Det är __1__ spelare online
map-time=Den här kartan har varit igång under __1__
join-us=Var snäll och förena dig med oss:
discord=Discord: https://discord.explosivegaming.nl
website=Website: explosivegaming.nl
custom-commands=Vi använder oss av specialiserade kommandon, som till exempel /tag och /report, se kommandotabben i readme för mer information.
read-readme=Se till att du har läst "Readme" (Finn den genom att klicka på frågetecknet högst upp i vänstra hörnet)

View File

@@ -0,0 +1,20 @@
{
"name": "ExpGamingBot.autoMessage",
"version": "4.0.0",
"description": "Prints a message every 15 minutes to chat.",
"location": "FSM_ARCHIVE",
"keywords": [
"Bot",
"Chat",
"Auto Message",
"Message"
],
"dependencies": {
"ExpGamingCore.Server": "^4.0.0",
"FactorioStdLib.Game": "^0.8.0",
"ExpGamingCore.Role": "?^4.0.0",
"ExpGamingCore.Sync": "?^4.0.0"
},
"collection": "ExpGamingBot@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,63 @@
--- Sends alerts to discord once there is a bot set up to read the alerts.
-- @module ExpGamingBot.discordAlerts@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alias ThisModule
-- Module Require
local Sync = require('ExpGamingCore.Sync')
local Color = require('FactorioStdLib.Color')
local Game = require('FactorioStdLib.Game')
-- Module Define
local module_verbose = false
local ThisModule = {}
-- Event Handlers Define
Event.add(defines.events.on_console_command,function(event)
local command = event.command
local args = {}
if event.parameters then for word in event.parameters:gmatch('%S+') do table.insert(args,word) end end
local data = {}
data.title = string.gsub(command,'^%l',string.upper)
data.by = event.player_index and game.players[event.player_index].name or '<server>'
if data.by == '<server>' then return end
if command == 'config' or command == 'banlist' then
Sync.emit_embedded{
title='Edit To '..data.title,
color=Color.to_hex(defines.textcolor.bg),
description='A player edited the '..command..'.',
['By:']=data.by,
['Edit:']=table.concat(args,' ',1)
}
else
if command == 'ban' then
data.colour = Color.to_hex(defines.textcolor.crit)
data.reason = table.concat(args,' ',2)
elseif command == 'kick' then
data.colour = Color.to_hex(defines.textcolor.high)
data.reason = table.concat(args,' ',2)
elseif command == 'unban' then data.colour = Color.to_hex(defines.textcolor.low)
elseif command == 'mute' then data.colour = Color.to_hex(defines.textcolor.med)
elseif command == 'unmute' then data.colour = Color.to_hex(defines.textcolor.low)
elseif command == 'promote' then data.colour = Color.to_hex(defines.textcolor.info)
elseif command == 'demote' then data.colour = Color.to_hex(defines.textcolor.info)
elseif command == 'purge' then data.colour = Color.to_hex(defines.textcolor.med)
else return end
data.username = args[1]
if not Game.get_player(data.username) then return end
if string.sub(command,-1) == 'e' then data.command = command..'d' else data.command = command..'ed' end
data.reason = data.reason and data.reason ~= '' and data.reason or 'No Reason Required'
Sync.emit_embedded{
title='Player '..data.title,
color=data.colour,
description='There was a player '..data.command..'.',
['Player:']='<<inline>>'..data.username,
['By:']='<<inline>>'..data.by,
['Reason:']=data.reason
}
end
end)
-- Module Return
return ThisModule

View File

@@ -0,0 +1,20 @@
{
"name": "ExpGamingBot.discordAlerts",
"version": "4.0.0",
"description": "Sends alerts to discord once there is a bot set up to read the alerts.",
"location": "FSM_ARCHIVE",
"keywords": [
"Bot",
"Discord",
"Alerts",
"Messages",
"Acctions"
],
"dependencies": {
"ExpGamingCore.Sync": "^4.0.0",
"FactorioStdLib.Color": "^0.8.0",
"FactorioStdLib.Game": "^0.8.0"
},
"collection": "ExpGamingBot@4.0.0",
"submodules": {}
}

View File

@@ -0,0 +1,22 @@
{
"name": "ExpGamingBot",
"version": "4.0.0",
"description": "Different parts of a useful bot to help run a server. Discord Bot Not Included.",
"location": "FSM_ARCHIVE",
"keywords": [
"Discord",
"Bot",
"Messages",
"Chat",
"Auto"
],
"author": "Cooldude2606",
"contact": "Discord: Cooldude2606#5241",
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
"submodules": {
"ExpGamingBot.autoChat": "4.0.0",
"ExpGamingBot.autoMessage": "4.0.0",
"ExpGamingBot.discordAlerts": "4.0.0"
},
"dependencies": {}
}