Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
happy-botday
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guillaume Vagner
happy-botday
Commits
1102f224
Commit
1102f224
authored
6 years ago
by
Guillaume Vagner
Browse files
Options
Downloads
Patches
Plain Diff
rebootproof
parent
65b29782
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
connection-db.js
+9
-1
9 additions, 1 deletion
connection-db.js
schedule.js
+9
-10
9 additions, 10 deletions
schedule.js
telegram.js
+5
-4
5 additions, 4 deletions
telegram.js
with
23 additions
and
15 deletions
connection-db.js
+
9
−
1
View file @
1102f224
...
...
@@ -105,5 +105,13 @@ function getGroups(chatId) {
})
}
function
getSchedules
()
{
return
query
(
`
SELECT *
FROM channel
WHERE schedule <> ""
`
)
}
module
.
exports
=
{
query
,
getChanByChatId
,
createChan
,
deleteChanByChatId
,
modifyChan
,
getChanByState
,
addGroup
,
getGroups
};
\ No newline at end of file
module
.
exports
=
{
query
,
getChanByChatId
,
createChan
,
deleteChanByChatId
,
modifyChan
,
getChanByState
,
addGroup
,
getGroups
,
getSchedules
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
schedule.js
+
9
−
10
View file @
1102f224
...
...
@@ -2,23 +2,22 @@
var
schedule
=
require
(
'
node-schedule
'
);
// Modules propres
var
{
modifyChan
,
getGroups
}
=
require
(
'
./connection-db
'
);
var
{
modifyChan
,
getGroups
,
getSchedules
}
=
require
(
'
./connection-db
'
);
var
{
getBirthdays
,
getNewToken
}
=
require
(
'
./requests
'
);
var
bot
=
require
(
'
./telegram
'
);
// Création de variables
var
schedules
=
{};
getSchedules
().
then
(
chans
=>
{
chans
.
forEach
(
chan
=>
{
addSchedule
(
chan
,
chan
.
schedule
)
})
console
.
log
(
`[schdles] reload schedules`
)
})
// En cas de redémarrage de l'appli
// query(`SELECT chatId, schedule FROM channel WHERE schedule <> ""`).then(rep => {
// rep.forEach(chan => {
//
// })
// })
function
addSchedule
(
chan
,
time
,
bot
)
{
function
addSchedule
(
chan
,
time
)
{
const
hour
=
parseInt
(
time
.
split
(
'
:
'
)[
0
]);
const
minute
=
parseInt
(
time
.
split
(
'
:
'
)[
1
]);
chan
.
schedule
=
time
;
...
...
This diff is collapsed.
Click to expand it.
telegram.js
+
5
−
4
View file @
1102f224
...
...
@@ -168,7 +168,7 @@ bot.onText(/\/add (.+)/, (msg, match) => {
})
// Ajout d
u temps de schedule
// Ajout d
'un rappel
bot
.
onText
(
/
\/
schedule
(
.+
)
/
,
(
msg
,
match
)
=>
{
const
chatId
=
msg
.
chat
.
id
;
const
time
=
match
[
1
];
...
...
@@ -180,19 +180,20 @@ bot.onText(/\/schedule (.+)/, (msg, match) => {
bot
.
sendMessage
(
chatId
,
`Votre rappel est configuré pour tous les jours à
${
time
}
`
);
})
// Suppression du rappel
bot
.
onText
(
/
\/
unschedule/
,
msg
=>
{
const
chatId
=
msg
.
chat
.
id
;
getChanByChatId
(
chatId
).
then
(
chan
=>
{
if
(
!
chan
)
return
bot
.
sendMessage
(
chatId
,
'
Pas de compte enregistré, faites /start pour commencer
'
);
if
(
chan
.
tim
e
==
''
)
return
bot
.
sendMessage
(
chatId
,
'
Pas de rappel défini...
'
);
if
(
chan
.
schedul
e
==
''
)
return
bot
.
sendMessage
(
chatId
,
'
Pas de rappel défini...
'
);
deleteSchedule
(
chatId
)
chan
.
tim
e
=
''
chan
.
schedul
e
=
''
return
modifyChan
(
chan
)
}).
then
(
_
=>
{
bot
.
sendMessage
(
chatId
,
'
Votre rappel a été supprimé.
'
)
})
})
// J'étais bien obligé (en vrai c'est pour tester)
...
...
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