Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Signalbot
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Frederic Aust
Signalbot
Commits
d69586be
Commit
d69586be
authored
3 years ago
by
Frederic Aust
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix: next - Days +1 to fix <48h Issue and modified birthday tomorrow text
parent
e8c23ccb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mod_birthdayreminder.py
+31
-19
31 additions, 19 deletions
mod_birthdayreminder.py
with
31 additions
and
19 deletions
mod_birthdayreminder.py
+
31
−
19
View file @
d69586be
...
...
@@ -26,12 +26,11 @@ class Birthday:
# comp = splittedDateSelf[1].__cmp__(splittedDateOther[1]) # compare month
# if comp == 0:
# comp = splittedDateSelf[0].__cmp__(splittedDateOther[0]) # compare day
#
#
if comp == 0:
# if comp == 0:
# comp = self.PERSON.__cmp__(other.PERSON) # compare name
#
# return comp
def
get_congratulation
(
self
):
return
f
"
Alles Gute
{
self
.
PERSON
}
❤
"
...
...
@@ -80,7 +79,8 @@ class ModuleBirthdayReminder:
if
dm
==
birthday
.
DATE
:
for
group
in
self
.
GROUPS
:
if
group
[
"
NAME
"
]
==
key
:
self
.
send
(
birthday
.
get_congratulation
(),
group
[
"
ID
"
])
self
.
send
(
birthday
.
get_congratulation
(),
group
[
"
ID
"
])
break
def
get_next_birthday
(
self
,
groupInfo
):
...
...
@@ -93,7 +93,8 @@ class ModuleBirthdayReminder:
# Dieses Jahr
birthday_string
=
f
"
{
birthday
.
DATE
}
.
{
date
.
today
().
strftime
(
'
%Y
'
)
}
"
birthday_dt
=
datetime
.
strptime
(
birthday_string
,
format
)
delta_temp
=
(
birthday_dt
-
today
).
days
delta_temp
=
(
birthday_dt
-
today
).
days
+
1
# Damit er bei 47h nicht 1 Tag sagt
if
0
<
delta_temp
<
delta
:
next_birthday
=
birthday
delta
=
delta_temp
...
...
@@ -101,13 +102,18 @@ class ModuleBirthdayReminder:
# Nächstes Jahr (Für den Jahresüberlauf)
next_year
=
date
.
today
()
+
relativedelta
(
years
=
1
)
birthday_next_year_string
=
f
"
{
birthday
.
DATE
}
.
{
next_year
.
strftime
(
'
%Y
'
)
}
"
birthday_next_year
=
datetime
.
strptime
(
birthday_next_year_string
,
format
)
delta_temp
=
(
birthday_next_year
-
today
).
days
birthday_next_year
=
datetime
.
strptime
(
birthday_next_year_string
,
format
)
delta_temp
=
(
birthday_next_year
-
today
).
days
+
1
# Damit er bei 47h nicht 1 Tag sagt
if
delta_temp
<
delta
:
next_birthday
=
birthday
delta
=
delta_temp
message
=
"
Niemand hat hier Geburtstag! Wir sind in einer Zeitschleife gefangen.
"
if
next_birthday
:
if
delta
==
1
:
message
=
f
"
Morgen hat
{
next_birthday
.
PERSON
}
Geburtstag!🎉
"
else
:
message
=
f
"
Als nächstes hat
{
next_birthday
.
PERSON
}
am
{
next_birthday
.
DATE
}
Geburtstag (noch
{
delta
}
Tage)
"
return
message
...
...
@@ -123,20 +129,24 @@ class ModuleBirthdayReminder:
def
interpret_birthday_line
(
self
,
line
):
splitted
=
line
.
strip
().
split
(
"
,
"
)
if
len
(
splitted
)
!=
2
:
raise
SyntaxError
(
"
Invalid birthday syntax! Needs to be: person, date(Day.Month) eg.: Karl, 02.09
"
)
raise
SyntaxError
(
"
Invalid birthday syntax! Needs to be: person, date(Day.Month) eg.: Karl, 02.09
"
)
person
=
splitted
[
0
].
strip
()
if
len
(
person
)
==
0
:
raise
SyntaxError
(
"
No name given! Needs to be: person, date(Day.Month) eg.: Karl, 02.09
"
)
raise
SyntaxError
(
"
No name given! Needs to be: person, date(Day.Month) eg.: Karl, 02.09
"
)
splittedDate
=
splitted
[
1
].
strip
().
split
(
"
.
"
)
if
len
(
splitted
)
!=
2
:
raise
SyntaxError
(
"
Invalid date! Needs to be: person, date(Day.Month) eg.: Karl, 02.09
"
)
raise
SyntaxError
(
"
Invalid date! Needs to be: person, date(Day.Month) eg.: Karl, 02.09
"
)
day
=
splittedDate
[
0
].
strip
()
month
=
splittedDate
[
1
].
strip
()
if
len
(
day
)
>
2
or
len
(
month
)
>
2
or
len
(
day
)
==
0
or
len
(
month
)
==
0
:
raise
SyntaxError
(
"
Invalid date! Needs to be: person, date(Day.Month) eg.: Karl, 02.09
"
)
raise
SyntaxError
(
"
Invalid date! Needs to be: person, date(Day.Month) eg.: Karl, 02.09
"
)
if
len
(
day
)
==
1
:
day
=
f
"
0
{
day
}
"
if
len
(
month
)
==
1
:
...
...
@@ -155,7 +165,8 @@ class ModuleBirthdayReminder:
self
.
birthday_list
[
groupInfo
[
"
NAME
"
]].
append
(
birthday
)
except
(
SyntaxError
,
ValueError
)
as
exc
:
self
.
log
.
warning
(
f
"
{
self
.
tag
}
Error while interpreting birthday line:
{
message
}
; Error:
{
exc
}
"
)
self
.
log
.
warning
(
f
"
{
self
.
tag
}
Error while interpreting birthday line:
{
message
}
; Error:
{
exc
}
"
)
return
f
"
{
exc
}
"
try
:
...
...
@@ -163,5 +174,6 @@ class ModuleBirthdayReminder:
f
.
write
(
f
"
{
birthday
.
get_csv_line
()
}
\n
"
)
return
"
Successfully added birthday
"
except
IOError
as
exc
:
self
.
log
.
error
(
f
"
{
self
.
tag
}
Adding new birthday
'
{
birthday
.
get_csv_line
()
}
'
to file failed:
{
exc
}
"
)
self
.
log
.
error
(
f
"
{
self
.
tag
}
Adding new birthday
'
{
birthday
.
get_csv_line
()
}
'
to file failed:
{
exc
}
"
)
return
"
Saving birthday failed
"
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