Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
strolly
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
dnns01
strolly
Commits
20a9b4a7
Commit
20a9b4a7
authored
2 years ago
by
dnns01
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup forecasts to show only current weeks forecast and highlight today in forecast
parent
2269fcdb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extensions/schedule.py
+17
-0
17 additions, 0 deletions
extensions/schedule.py
with
17 additions
and
0 deletions
extensions/schedule.py
+
17
−
0
View file @
20a9b4a7
...
@@ -122,6 +122,7 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
...
@@ -122,6 +122,7 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
end_day
=
start_day
+
timedelta
(
days
=
6
)
end_day
=
start_day
+
timedelta
(
days
=
6
)
schedule_channel
=
await
self
.
bot
.
fetch_channel
(
int
(
os
.
getenv
(
"
SCHEDULE_CHANNEL
"
)))
schedule_channel
=
await
self
.
bot
.
fetch_channel
(
int
(
os
.
getenv
(
"
SCHEDULE_CHANNEL
"
)))
await
self
.
cleanup_forecast
(
schedule_channel
)
week_schedule
=
Schedule
.
get_or_none
(
calendar_week
=
calendar_week
,
calendar_year
=
start_day
.
year
)
week_schedule
=
Schedule
.
get_or_none
(
calendar_week
=
calendar_week
,
calendar_year
=
start_day
.
year
)
embed
=
discord
.
Embed
(
title
=
f
"
Contentvorhersage für die
{
calendar_week
}
. Kalenderwoche
"
,
embed
=
discord
.
Embed
(
title
=
f
"
Contentvorhersage für die
{
calendar_week
}
. Kalenderwoche
"
,
...
@@ -133,6 +134,10 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
...
@@ -133,6 +134,10 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
while
curr_day
<=
end_day
:
while
curr_day
<=
end_day
:
name
=
f
"
{
get_weekday
(
curr_day
)
}
{
curr_day
.
strftime
(
'
%d.%m.%Y
'
)
}
"
name
=
f
"
{
get_weekday
(
curr_day
)
}
{
curr_day
.
strftime
(
'
%d.%m.%Y
'
)
}
"
value
=
""
value
=
""
if
curr_day
.
day
==
datetime
.
now
().
day
:
name
=
f
"
>>
{
name
}
<<
"
for
segment
in
ScheduleSegment
.
select
()
\
for
segment
in
ScheduleSegment
.
select
()
\
.
where
(
ScheduleSegment
.
start_time
.
between
(
curr_day
,
(
curr_day
+
timedelta
(
days
=
1
))))
\
.
where
(
ScheduleSegment
.
start_time
.
between
(
curr_day
,
(
curr_day
+
timedelta
(
days
=
1
))))
\
.
order_by
(
ScheduleSegment
.
start_time
):
.
order_by
(
ScheduleSegment
.
start_time
):
...
@@ -175,6 +180,18 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
...
@@ -175,6 +180,18 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
remove_cancelled_streams
(
user
,
schedule
.
segments
)
remove_cancelled_streams
(
user
,
schedule
.
segments
)
async
def
cleanup_forecast
(
self
,
schedule_channel
):
now
=
datetime
.
now
()
calendar
=
now
.
isocalendar
()
for
schedule
in
Schedule
.
select
().
where
(
Schedule
.
calendar_week
<=
calendar
.
week
-
1
):
try
:
message
=
await
schedule_channel
.
fetch_message
(
schedule
.
message_id
)
await
message
.
delete
()
except
:
pass
schedule
.
delete_instance
(
recursive
=
True
)
async
def
setup
(
bot
:
commands
.
Bot
)
->
None
:
async
def
setup
(
bot
:
commands
.
Bot
)
->
None
:
await
bot
.
add_cog
(
TwitchSchedule
(
bot
))
await
bot
.
add_cog
(
TwitchSchedule
(
bot
))
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