Repository navigation
Commit fe5e47c
feat: post all livestream URLs upfront instead of per-session (#376)
* feat: post all livestream URLs upfront instead of per-session
* Refactor: Move `post_all_livestream_urls` to the correct position
This method is analogous to `notify_sessions`, so it should be located next to it, instead of between `on_ready` and `cog_load`.
* Refactor: Rename `post_all_livestream_urls` to `notify_livestreams`
This method is analogous to `notify_sessions`, so it should be named similarly.
* Run `notify_livestreams` in a loop instead of once on startup
Like the schedule, the livestream URLs can change while the program is running. That's why we fetch them regularly.
So the task `notify_livestreams` should run regularly, like `notify_sessions`.
* Don't trigger a fetch if no livestreams are found
The livestreams are fetched regularly (every 5 minutes). Let's just wait for the regular fetch instead of triggering a second one. Also, it might be that there really are no livestreams to fetch.
* Only obtain livestreams_by_room once
This change is quite pedantic, but I want to get this information from the livestream_connector exactly once. Otherwise, it could (theoretically) change between the first and second access.
* Restore previous livestream format
Before adding this feature, the format was `Livestream: [YouTube](<URL>)`, using Markdown to display a lable instead of the plain URL. Let's keep it like that and only add the day.
* Always use English weekdays
`date.strftime('%A')` returns the "Weekday as locale’s full name" (quote from https://docs.python.org/3/library/datetime.html#format-codes).
We always want English output, even if the bot host is configured in another locale.
* ProgrammeConnector: Make current time publicly available
This is necessary for the next step: Only sending livestream URLs a day in advance.
(A cleaner approach would be to extract the 'current time' logic into a separate service, but this approach doesn't cause much chaos, so it's okay.)
* Only post livestream URLs a day in advance
Also add the headline 'Channel for room {room_name}'.
---------
Co-authored-by: Niklas Mertsch <niklasmertsch@web.de>1 parent deab252 commit fe5e47c
3 files changed
Lines changed: 54 additions & 13 deletions
File tree
- src/europython_discord/programme_notifications
- tests/program_notifications
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
18 | 28 | | |
19 | 29 | | |
20 | 30 | | |
| |||
40 | 50 | | |
41 | 51 | | |
42 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
43 | 56 | | |
44 | 57 | | |
45 | 58 | | |
46 | 59 | | |
47 | 60 | | |
48 | 61 | | |
49 | | - | |
50 | | - | |
51 | | - | |
| 62 | + | |
52 | 63 | | |
53 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
54 | 68 | | |
55 | 69 | | |
56 | 70 | | |
57 | | - | |
| 71 | + | |
58 | 72 | | |
59 | 73 | | |
60 | 74 | | |
| |||
74 | 88 | | |
75 | 89 | | |
76 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
77 | 121 | | |
78 | 122 | | |
79 | 123 | | |
| |||
105 | 149 | | |
106 | 150 | | |
107 | 151 | | |
108 | | - | |
| 152 | + | |
109 | 153 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 154 | | |
114 | 155 | | |
115 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
0 commit comments