Added ExpGamingBot

This commit is contained in:
Cooldude2606
2018-08-14 18:53:01 +01:00
parent 0b67b8a7b5
commit 3f66d0bda0
36 changed files with 388 additions and 56 deletions

View File

@@ -1,134 +0,0 @@
--[[
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 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'},
['link']={'chat-bot.links'},
['links']={'chat-bot.links'},
['loop']={'chat-bot.loops'},
['loops']={'chat-bot.loops'},
--Thadius suggestion start
['rhd']={'chat-bot.lhd'},
--Thadius suggestion end
['roundabout']={'chat-bot.loops'},
['roundabouts']={'chat-bot.loops'},
['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 {'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 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 = {'Cooldude2606','arty714','badgamernl',player.name} return {'chat-bot.blame',names[math.random(#names)]} end,
['readme']={'chat-bot.read-readme'},
['magic']={'chat-bot.magic'},
['aids']={'chat-bot.aids'},
['riot']={'chat-bot.riot'},
['lenny']={'chat-bot.lenny'},
['wiki']={'chat-bot.wiki'},
['evolution']=function(player) return {'chat-bot.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)} end,
--Jokes about food and drink
['whattoeat']={'chat-bot.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{'chat-bot.message',{'chat-bot.get-popcorn-2',self.data}} end
end):open() return {'chat-bot.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{'chat-bot.message',{'chat-bot.order-pizza-2',self.data[1]}}
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.order-pizza-3',self.data[1]}} self.reopen = false
end
self.data[2]=self.data[2]+1
end):open() return {'chat-bot.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{'chat-bot.message',{'chat-bot.get-snaps-2',self.data[1]}}
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.get-snaps-3',self.data[1]}} self.reopen = false
end
self.data[2]=self.data[2]+1
end):open() return {'chat-bot.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{'chat-bot.message',{'chat-bot.get-cocktail-2',self.data[1]}}
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.get-cocktail-3',self.data[1]}} self.reopen = false
end
self.data[2]=self.data[2]+1
end):open() return {'chat-bot.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{'chat-bot.message',{'chat-bot.make-coffee-2',self.data}} end
end):open() return {'chat-bot.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{'chat-bot.message',{'chat-bot.order-pizza-2',self.data[1]}}
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.order-pizza-3',self.data[1]}} self.reopen = false
end
self.data[2]=self.data[2] + 1
end):open() return {'chat-bot.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{'chat-bot.message',{'chat-bot.make-tea-2',self.data}} end
end):open() return {'chat-bot.make-tea-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{'chat-bot.message',{'chat-bot.get-mead-2',self.data}} end
end):open() return {'chat-bot.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{'chat-bot.message',{'chat-bot.get-beer-2',self.data}} end
end):open() return {'chat-bot.get-beer-1'} end
}
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)

View File

@@ -1,61 +0,0 @@
--[[
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-----------------------------------------------------------
Event.register(-1,function(event)
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_rank= 'Owner',
low_rank= 'Regular',
low={
{'chat-bot.join-us'},
{'chat-bot.discord'},
{'chat-bot.website'},
{'chat-bot.custom-commands'},
{'chat-bot.read-readme'}
}
}
}:on_event('timeout',function(self)
local data = self.data
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)
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
-- idk but this stoped working for no appent reason so i added more checks for nil values
if Ranking.get_rank(player).power <= Ranking.get_rank(data.low_rank).power then 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)
Sync.emit_embeded{
title='Auto Message Error',
color=Color.to_hex(defines.text_color.bg),
description='Auto Message Error - Closed Thread',
Error=err
}
self.reopen = false
self:close()
end):open()
end)

View File

@@ -1,54 +0,0 @@
--[[
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-----------------------------------------------------------
Event.register(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_embeded{
title='Edit To '..data.title,
color=Color.to_hex(defines.text_color.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.text_color.crit)
data.reason = table.concat(args,' ',2)
elseif command == 'kick' then
data.colour = Color.to_hex(defines.text_color.high)
data.reason = table.concat(args,' ',2)
elseif command == 'unban' then data.colour = Color.to_hex(defines.text_color.low)
elseif command == 'mute' then data.colour = Color.to_hex(defines.text_color.med)
elseif command == 'unmute' then data.colour = Color.to_hex(defines.text_color.low)
elseif command == 'promote' then data.colour = Color.to_hex(defines.text_color.info)
elseif command == 'demote' then data.colour = Color.to_hex(defines.text_color.info)
elseif command == 'purge' then data.colour = Color.to_hex(defines.text_color.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_embeded{
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)