Skip to content
Snippets Groups Projects
Commit bcdeb3dc authored by Diego's avatar Diego
Browse files

corrects the name of events/tempo.coffee to events/programacao.coffee

parent 31dce57a
No related branches found
No related tags found
No related merge requests found
path = require 'path'
natural = require 'natural'
programacao = require '../programacao.json'
{msgVariables, stringElseRandomKey} = require path.join '..', 'lib', 'common.coffee'
answers = {}
class programacao
currentDate = new Date
currentDate.getTimezoneOffset()
getTrilha = (programacao, trilha, now = false) ->
currentTime = "#{currentDate.getHours()}:#{currentDate.getMinutes()}"
programacao.filter (item) ->
startTime = item.time[0]
endTime = item.time[1]
return item.track_title is trilha and ((not now and startTime > currentTime) or (now and startTime < currentTime and endTime > currentTime))
class tempo
constructor: (@interaction) ->
process: (msg) =>
# localizar a trilha na mensagem do usuário
process: (msg, text, classification) =>
type = @interaction.type?.toLowerCase() or 'random'
# carregar o json com a programacao
programa = require './programacao.json'
variables = {
trilha: classification[0].label
programacao: ''
}
#encontra a trilha e retorna a programação deste horário
currentTalk = getTrilha programacao, variables.trilha, true
nextTalks = getTrilha programacao, variables.trilha
if currentTalk.length
variables.programacao += "*Acontecendo agora*: \n" + currentTalk.map((talk) ->
return "- *#{talk.time[0]} - #{talk.time[1]}* - #{talk.title}"
).join("\n")
variables.programacao += "\n\n"
if nextTalks.length
variables.programacao += "*Próximas palestras*: \n" + nextTalks.map((talk) ->
return "- *#{talk.time[0]} - #{talk.time[1]}* - #{talk.title}"
).join("\n")
type = @interaction.type?.toLowerCase() or 'random'
switch type
when 'block'
@interaction.message.forEach (line) ->
message = msgVariables line, msg
msg['send'] message
messages = @interaction.message.map (line) ->
return msgVariables line, msg, variables
msg.sendWithNaturalDelay messages
when 'random'
message = stringElseRandomKey @interaction.message
message = msgVariables message, msg
msg['send'] message
message = msgVariables message, msg, variables
msg.sendWithNaturalDelay message
module.exports = programacao
module.exports = tempo
path = require 'path'
natural = require 'natural'
programacao = require '../programacao.json'
{msgVariables, stringElseRandomKey} = require path.join '..', 'lib', 'common.coffee'
answers = {}
currentDate = new Date
currentDate.getTimezoneOffset()
getTrilha = (programacao, trilha, now = false) ->
currentTime = "#{currentDate.getHours()}:#{currentDate.getMinutes()}"
programacao.filter (item) ->
startTime = item.time[0]
endTime = item.time[1]
return item.track_title is trilha and ((not now and startTime > currentTime) or (now and startTime < currentTime and endTime > currentTime))
class tempo
constructor: (@interaction) ->
process: (msg, text, classification) =>
type = @interaction.type?.toLowerCase() or 'random'
variables = {
trilha: classification[0].label
programacao: ''
}
currentTalk = getTrilha programacao, variables.trilha, true
nextTalks = getTrilha programacao, variables.trilha
if currentTalk.length
variables.programacao += "*Acontecendo agora*: \n" + currentTalk.map((talk) ->
return "- *#{talk.time[0]} - #{talk.time[1]}* - #{talk.title}"
).join("\n")
variables.programacao += "\n\n"
if nextTalks.length
variables.programacao += "*Próximas palestras*: \n" + nextTalks.map((talk) ->
return "- *#{talk.time[0]} - #{talk.time[1]}* - #{talk.title}"
).join("\n")
switch type
when 'block'
messages = @interaction.message.map (line) ->
return msgVariables line, msg, variables
msg.sendWithNaturalDelay messages
when 'random'
message = stringElseRandomKey @interaction.message
message = msgVariables message, msg, variables
msg.sendWithNaturalDelay message
module.exports = tempo
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment