Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
ru-bot-telegram
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
Harbor 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CAAD
ru-bot-telegram
Commits
fb58aa56
Commit
fb58aa56
authored
3 years ago
by
fmk17
Browse files
Options
Downloads
Patches
Plain Diff
Add indicator descriptions
parent
a1bddd0e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+34
-13
34 additions, 13 deletions
main.py
model.py
+14
-7
14 additions, 7 deletions
model.py
with
48 additions
and
20 deletions
main.py
+
34
−
13
View file @
fb58aa56
...
@@ -67,29 +67,50 @@ def format_user(user):
...
@@ -67,29 +67,50 @@ def format_user(user):
def
format_location_days
(
location_days
):
def
format_location_days
(
location_days
):
days
,
location
,
update_datetime
=
location_days
days
,
location
,
update_datetime
=
location_days
header
=
f
"
<b>RU
{
location
.
name
}
</b>
"
used_indicators
=
set
()
strings
=
[]
strings
.
append
(
f
"
<b>RU
{
location
.
name
}
</b>
"
)
if
len
(
days
):
if
len
(
days
):
body
=
"
\n\n
"
.
join
(
for
day
in
days
:
for
menu
in
day
.
menus
:
for
item
in
menu
.
items
:
used_indicators
|=
item
.
indicators
strings
.
append
(
"
\n\n
"
.
join
(
f
"
<b>
{
day
.
date_raw
}
</b>
\n
"
f
"
<b>
{
day
.
date_raw
}
</b>
\n
"
+
"
\n
"
.
join
(
+
"
\n
"
.
join
(
f
"
<b>
{
menu
.
meal_name
}
</b>
\n
"
f
"
<b>
{
menu
.
meal_name
}
</b>
\n
"
+
"
\n
"
.
join
(
+
"
\n
"
.
join
(
f
"
•
{
item
.
name
}
"
f
"
•
{
item
.
name
}
"
+
""
.
join
(
indicator
.
emoji
for
indicator
in
item
.
indicators
)
+
""
.
join
(
indicator
.
emoji
for
indicator
in
sorted
(
item
.
indicators
)
)
for
item
in
menu
.
items
for
item
in
menu
.
items
)
)
for
menu
in
day
.
menus
for
menu
in
day
.
menus
)
)
for
day
in
days
for
day
in
days
)
)
)
else
:
else
:
body
=
"
<i>Cardápio indisponível</i>
"
strings
.
append
(
"
<i>Cardápio indisponível</i>
"
)
updated_on
=
(
if
len
(
used_indicators
):
strings
.
append
(
"
<b>Legenda:</b>
\n
"
+
"
\n
"
.
join
(
f
"
•
{
indicator
.
emoji
}
·
{
indicator
.
description
}
"
for
indicator
in
sorted
(
used_indicators
)
)
)
strings
.
append
(
"
<i>Atualizado às
"
"
<i>Atualizado às
"
+
update_datetime
.
strftime
(
"
%H:%M:%S
"
)
+
update_datetime
.
strftime
(
"
%H:%M:%S
"
)
+
"
de hoje</i>
"
+
"
de hoje</i>
"
)
)
return
header
+
"
\n\n
"
+
body
+
"
\n\n
"
+
updated_on
return
"
\n\n
"
.
join
(
strings
)
@dataclass
@dataclass
...
...
This diff is collapsed.
Click to expand it.
model.py
+
14
−
7
View file @
fb58aa56
...
@@ -37,24 +37,31 @@ WorkingWeekDay = [
...
@@ -37,24 +37,31 @@ WorkingWeekDay = [
class
MenuItemIndicator
(
Enum
):
class
MenuItemIndicator
(
Enum
):
VEGAN
=
(
"
🌱
"
,
"
Indicado para veganos
"
)
VEGAN
=
(
1
,
"
🌱
"
,
"
Indicado para veganos
"
)
GLUTEN
=
(
"
🌾
"
,
"
Não indicado para celíacos por conter glúten
"
)
GLUTEN
=
(
2
,
"
🌾
"
,
"
Não indicado para celíacos por conter glúten
"
)
LACTOSE
=
(
LACTOSE
=
(
3
,
"
🥛
"
,
"
🥛
"
,
"
Não indicado para intolerantes à lactose por conter lactose
"
,
"
Não indicado para intolerantes à lactose por conter lactose
"
,
)
)
ANIMAL
=
(
"
🥩
"
,
"
Contém produtos de origem animal
"
)
ANIMAL
=
(
4
,
"
🥩
"
,
"
Contém produtos de origem animal
"
)
EGG
=
(
"
🥚
"
,
"
Contém ovo
"
)
EGG
=
(
5
,
"
🥚
"
,
"
Contém ovo
"
)
HONEY
=
(
"
🍯
"
,
"
Contém mel
"
)
HONEY
=
(
6
,
"
🍯
"
,
"
Contém mel
"
)
ALERGIC
=
(
"
⚠️
"
,
"
Contém produto(s) alergênico(s)
"
)
ALERGIC
=
(
7
,
"
⚠️
"
,
"
Contém produto(s) alergênico(s)
"
)
def
__new__
(
cls
,
emoji
,
description
):
def
__new__
(
cls
,
ordering
,
emoji
,
description
):
obj
=
object
.
__new__
(
cls
)
obj
=
object
.
__new__
(
cls
)
obj
.
_value_
=
(
emoji
,
description
)
obj
.
_value_
=
(
emoji
,
description
)
obj
.
ordering
=
ordering
obj
.
emoji
=
emoji
obj
.
emoji
=
emoji
obj
.
description
=
description
obj
.
description
=
description
return
obj
return
obj
def
__lt__
(
self
,
other
):
if
self
.
__class__
is
other
.
__class__
:
return
self
.
ordering
<
other
.
ordering
return
NotImplemented
@dataclass
(
frozen
=
True
)
@dataclass
(
frozen
=
True
)
class
MenuItem
:
class
MenuItem
:
...
...
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