Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hubot-natural
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
hubot-natural
Commits
bcdeb3dc
Commit
bcdeb3dc
authored
7 years ago
by
Diego
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/events/programacao.coffee
+37
-13
37 additions, 13 deletions
scripts/events/programacao.coffee
scripts/events/tempo.coffee
+0
-52
0 additions, 52 deletions
scripts/events/tempo.coffee
with
37 additions
and
65 deletions
scripts/events/programacao.coffee
+
37
−
13
View file @
bcdeb3dc
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
.
send
WithNaturalDelay
message
s
when
'random'
message
=
stringElseRandomKey
@
interaction
.
message
message
=
msgVariables
message
,
msg
msg
[
'
send
'
]
message
message
=
msgVariables
message
,
msg
,
variables
msg
.
send
WithNaturalDelay
message
module
.
exports
=
programaca
o
module
.
exports
=
temp
o
This diff is collapsed.
Click to expand it.
scripts/events/tempo.coffee
deleted
100644 → 0
+
0
−
52
View file @
31dce57a
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment