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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guillaume Vagner
happy-botday
Commits
d66e5437
Commit
d66e5437
authored
6 years ago
by
Guillaume Vagner
Browse files
Options
Downloads
Patches
Plain Diff
commands with @namebot
parent
15018584
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
telegram.js
+9
-9
9 additions, 9 deletions
telegram.js
with
9 additions
and
9 deletions
telegram.js
+
9
−
9
View file @
d66e5437
...
@@ -130,9 +130,9 @@ bot.onText(/\/birthdays/, msg => {
...
@@ -130,9 +130,9 @@ bot.onText(/\/birthdays/, msg => {
});
});
// recherche des groupes et renvoie le résultat avec leurs ID pour les rajouter
// recherche des groupes et renvoie le résultat avec leurs ID pour les rajouter
bot
.
onText
(
/
\/
search
(
.+
)
/
,
(
msg
,
match
)
=>
{
bot
.
onText
(
new
RegExp
(
`/search (.+)|/search@
${
config
.
telegram
.
name
}
(.+)`
)
,
(
msg
,
match
)
=>
{
const
chatId
=
msg
.
chat
.
id
;
const
chatId
=
msg
.
chat
.
id
;
const
research
=
match
[
1
];
const
research
=
match
[
0
].
split
(
'
'
)[
1
];
getChanByChatId
(
chatId
).
then
(
chan
=>
{
getChanByChatId
(
chatId
).
then
(
chan
=>
{
return
searchGroups
(
chan
,
research
)
return
searchGroups
(
chan
,
research
)
}).
then
(
groups
=>
{
}).
then
(
groups
=>
{
...
@@ -149,10 +149,10 @@ bot.onText(/\/search (.+)/, (msg, match) => {
...
@@ -149,10 +149,10 @@ bot.onText(/\/search (.+)/, (msg, match) => {
})
})
// Ajout d'un groupe dans la liste des groupes
// Ajout d'un groupe dans la liste des groupes
bot
.
onText
(
/
\/
add
(
.+
)
/
,
(
msg
,
match
)
=>
{
bot
.
onText
(
new
RegExp
(
`/add (.+)|/add@
${
config
.
telegram
.
name
}
(.+)
`
)
,
(
msg
,
match
)
=>
{
const
chatId
=
msg
.
chat
.
id
;
const
chatId
=
msg
.
chat
.
id
;
getChanByChatId
(
chatId
).
then
(
chan
=>
{
getChanByChatId
(
chatId
).
then
(
chan
=>
{
const
id
=
parseInt
(
match
[
1
].
split
(
'
'
)[
0
]);
const
id
=
parseInt
(
match
[
0
].
split
(
'
'
)[
1
]);
return
Promise
.
all
([
return
Promise
.
all
([
getGroupById
(
chan
,
id
),
getGroupById
(
chan
,
id
),
getGroups
(
chatId
),
getGroups
(
chatId
),
...
@@ -170,10 +170,10 @@ bot.onText(/\/add (.+)/, (msg, match) => {
...
@@ -170,10 +170,10 @@ bot.onText(/\/add (.+)/, (msg, match) => {
})
})
})
})
bot
.
onText
(
/
\/
del
(
.+
)
/
,
(
msg
,
match
)
=>
{
bot
.
onText
(
new
RegExp
(
`/del (.+)|/del@
${
config
.
telegram
.
name
}
(.+)
`
)
,
(
msg
,
match
)
=>
{
const
chatId
=
msg
.
chat
.
id
;
const
chatId
=
msg
.
chat
.
id
;
getChanByChatId
(
chatId
).
then
(
chan
=>
{
getChanByChatId
(
chatId
).
then
(
chan
=>
{
const
id
=
parseInt
(
match
[
1
].
split
(
'
'
)[
0
]);
const
id
=
parseInt
(
match
[
0
].
split
(
'
'
)[
1
]);
return
Promise
.
all
([
return
Promise
.
all
([
getGroupById
(
chan
,
id
),
getGroupById
(
chan
,
id
),
getGroups
(
chatId
),
getGroups
(
chatId
),
...
@@ -192,9 +192,9 @@ bot.onText(/\/del (.+)/, (msg, match) => {
...
@@ -192,9 +192,9 @@ bot.onText(/\/del (.+)/, (msg, match) => {
})
})
// Ajout d'un rappel
// Ajout d'un rappel
bot
.
onText
(
/
\
/
schedule
(
.+
)
/
,
(
msg
,
match
)
=>
{
bot
.
onText
(
new
RegExp
(
`
/schedule (.+)
|/schedule@
${
config
.
telegram
.
name
}
(.+)`
)
,
(
msg
,
match
)
=>
{
const
chatId
=
msg
.
chat
.
id
;
const
chatId
=
msg
.
chat
.
id
;
const
time
=
match
[
1
];
const
time
=
match
[
0
].
split
(
'
'
)[
1
];
if
(
!
RegExp
(
'
^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$
'
).
test
(
time
))
return
bot
.
sendMessage
(
chatId
,
'
Le temps entré n
\'
est pas au format hh:mm
'
);
if
(
!
RegExp
(
'
^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$
'
).
test
(
time
))
return
bot
.
sendMessage
(
chatId
,
'
Le temps entré n
\'
est pas au format hh:mm
'
);
getChanByChatId
(
chatId
).
then
(
chan
=>
{
getChanByChatId
(
chatId
).
then
(
chan
=>
{
if
(
!
chan
)
return
bot
.
sendMessage
(
chatId
,
'
Pas de compte enregistré, faites /start pour commencer
'
);
if
(
!
chan
)
return
bot
.
sendMessage
(
chatId
,
'
Pas de compte enregistré, faites /start pour commencer
'
);
...
...
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