diff options
| -rw-r--r-- | warmachine/addons/standup.py | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/warmachine/addons/standup.py b/warmachine/addons/standup.py index 0d46408..59c4f3c 100644 --- a/warmachine/addons/standup.py +++ b/warmachine/addons/standup.py | |||
| @@ -191,7 +191,19 @@ class StandUpPlugin(WarMachinePlugin): | |||
| 191 | 191 | ||
| 192 | def schedule_standup(self, connection, channel, time24h): | 192 | def schedule_standup(self, connection, channel, time24h): |
| 193 | """ | 193 | """ |
| 194 | Schedules a standup by creating a Task to be run in the future. | 194 | Schedules a standup by creating a Task to be run in the future. This |
| 195 | populates ``self.standup_schedules[channel]`` with the following keys: | ||
| 196 | - ``f`` (:class:`asyncio.Task`): This is the asyncio task object. | ||
| 197 | - ``datetime`` (:class:`datetime.datetime`): The datetime of when the | ||
| 198 | standup will run next. | ||
| 199 | - ``time24h`` (str): 24 hour time the schedule should be executed at. | ||
| 200 | - ``ignoring`` (list): List of usernames to ignore when asking for | ||
| 201 | their standup update. | ||
| 202 | |||
| 203 | Args: | ||
| 204 | connection (:class:`Connection`): the connection | ||
| 205 | channel (str): channel name to schedule standup for | ||
| 206 | time24h (str): The 24 hour time to start the standup at | ||
| 195 | """ | 207 | """ |
| 196 | next_standup = self.get_next_standup_secs(time24h) | 208 | next_standup = self.get_next_standup_secs(time24h) |
| 197 | 209 | ||
| @@ -202,12 +214,20 @@ class StandUpPlugin(WarMachinePlugin): | |||
| 202 | next_standup_secs, functools.partial( | 214 | next_standup_secs, functools.partial( |
| 203 | self.standup_schedule_func, connection, channel)) | 215 | self.standup_schedule_func, connection, channel)) |
| 204 | 216 | ||
| 205 | self.standup_schedules[channel] = { | 217 | # Don't overwrite existing setting if they exist |
| 206 | 'future': f, | 218 | if channel in self.standup_schedules: |
| 207 | 'datetime': next_standup, | 219 | self.standup_schedules[channel]['f'].cancel() |
| 208 | 'time24h': time24h, | 220 | |
| 209 | 'ignoring': [], | 221 | self.standup_schedules[channel]['f'] = f |
| 210 | } | 222 | self.standup_schedules[channel]['datetime'] = next_standup |
| 223 | self.standup_schedules[channel]['time24h'] = time24h | ||
| 224 | else: | ||
| 225 | self.standup_schedules[channel] = { | ||
| 226 | 'future': f, | ||
| 227 | 'datetime': next_standup, | ||
| 228 | 'time24h': time24h, | ||
| 229 | 'ignoring': [], | ||
| 230 | } | ||
| 211 | 231 | ||
| 212 | self.log.info('New schedule added to channel {} for {}'.format( | 232 | self.log.info('New schedule added to channel {} for {}'.format( |
| 213 | channel, time24h)) | 233 | channel, time24h)) |