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
2269fcdb
Commit
2269fcdb
authored
2 years ago
by
dnns01
Browse files
Options
Downloads
Patches
Plain Diff
Fix permissions for /schedule commands and let loop wait for the next full hour
parent
91c1312d
No related branches found
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
+16
-1
16 additions, 1 deletion
extensions/schedule.py
with
16 additions
and
1 deletion
extensions/schedule.py
+
16
−
1
View file @
2269fcdb
import
asyncio
import
base64
import
json
import
os
...
...
@@ -38,7 +39,8 @@ def remove_cancelled_streams(user, segments):
@app_commands.guild_only
@app_commands.default_permissions
(
manage_server
=
True
)
@app_commands.default_permissions
(
manage_guild
=
True
)
@app_commands.checks.has_permissions
(
manage_guild
=
True
)
class
TwitchSchedule
(
commands
.
GroupCog
,
name
=
"
schedule
"
):
def
__init__
(
self
,
bot
):
self
.
bot
=
bot
...
...
@@ -50,6 +52,8 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
@app_commands.describe
(
twitch_channel
=
"
Twitch channel to add
"
,
emoji
=
"
Emoji to be used for this channels entries in schedule
"
,
update_schedule
=
"
Define whether schedule should be updated or not.
"
)
@app_commands.default_permissions
(
manage_guild
=
True
)
@app_commands.checks.has_permissions
(
manage_guild
=
True
)
async
def
cmd_add
(
self
,
interaction
:
Interaction
,
twitch_channel
:
str
,
emoji
:
str
,
update_schedule
:
bool
=
False
):
await
interaction
.
response
.
defer
(
ephemeral
=
True
)
user
=
await
self
.
twitch_client
.
fetch_users
(
names
=
[
twitch_channel
])
...
...
@@ -72,6 +76,8 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
@app_commands.command
(
name
=
"
remove
"
,
description
=
"
Remove Twitch Channel from Schedule
"
)
@app_commands.describe
(
twitch_channel
=
"
Twitch Channel to remove
"
,
update_schedule
=
"
Define whether Schedule should be updated or not.
"
)
@app_commands.default_permissions
(
manage_guild
=
True
)
@app_commands.checks.has_permissions
(
manage_guild
=
True
)
async
def
cmd_remove
(
self
,
interaction
:
Interaction
,
twitch_channel
:
str
,
update_schedule
:
bool
=
False
):
await
interaction
.
response
.
defer
(
ephemeral
=
True
)
user
=
await
self
.
twitch_client
.
fetch_users
(
names
=
[
twitch_channel
])
...
...
@@ -92,6 +98,8 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
content
=
f
"
Twitch Kanal ist kein Teil des Kalenders.
"
)
@app_commands.command
(
name
=
"
update
"
,
description
=
"
Force to update the schedule
"
)
@app_commands.default_permissions
(
manage_guild
=
True
)
@app_commands.checks.has_permissions
(
manage_guild
=
True
)
async
def
cmd_update
(
self
,
interaction
:
Interaction
):
await
interaction
.
response
.
defer
(
ephemeral
=
True
)
await
self
.
update_schedule
()
...
...
@@ -101,6 +109,13 @@ class TwitchSchedule(commands.GroupCog, name="schedule"):
async
def
update_task
(
self
):
await
self
.
update_schedule
()
@update_task.before_loop
async
def
before_update_task
(
self
):
await
self
.
bot
.
wait_until_ready
()
now
=
datetime
.
now
()
diff
=
(
datetime
(
year
=
now
.
year
,
month
=
now
.
month
,
day
=
now
.
day
,
hour
=
now
.
hour
)
+
timedelta
(
hours
=
1
))
-
now
await
asyncio
.
sleep
(
diff
.
seconds
)
async
def
update_schedule
(
self
):
await
self
.
update_database
()
calendar_week
,
start_day
=
get_calendar_week
()
...
...
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