Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled close event for thread save to config vars #135

Merged
merged 25 commits into from
Jan 17, 2019
Merged

Scheduled close event for thread save to config vars #135

merged 25 commits into from
Jan 17, 2019

Conversation

Taaku18
Copy link
Collaborator

@Taaku18 Taaku18 commented Jan 17, 2019

According to Automatic dyno restarts, all dynos will restart at least once every 27 hours.

Dynos are also restarted (cycled) at least once per day to help maintain the health of applications running on Heroku. Any changes to the local filesystem will be deleted. The cycling happens once every 24 hours (plus up to 216 random minutes, to prevent every dyno for an application from restarting at the same time).

During this period, local caches are deleted, which results in the inability to set the scheduled closure time to longer than 24 hours.


This PR resolves this issue.

Fixes #134

  • Use call_later() instead of sleep() for scheduling.
  • Created a new internal config var: closures.
  • Bot:
    • loads closures upon start
    • removes closures['id'] upon deletion

Format:

'closures': {
    'recipient_id': {
        'time': 'ISO 8601 time string',
        'closer_id': int,
        'silent': bool,
        'delete_channel': bool,
        'message': 'message string'
    },
    ...
}
  • recipient_id (str) the id of the recipient, aka thread.id.
  • time (str) an 'ISO 8601 formatted datetime string.
  • closer_id (int) the user who initiated the closure of the thread.

The following are the same as the parameters of the close() function.

  • silent (bool)
  • delete_channel (bool)
  • message (str)

Unresolved Known Issues

  • During the bot's downtime (when bot restarts), messages during this period are ignored. Therefore the close schedule will not terminate.

Aside

#Addresses #133

  • Improved formatting in core/config.py

Please carefully review this PR and minor version bump upon approval.

core/thread.py Outdated Show resolved Hide resolved
core/thread.py Show resolved Hide resolved
core/config.py Show resolved Hide resolved
bot.py Outdated Show resolved Hide resolved
bot.py Outdated Show resolved Hide resolved
core/thread.py Outdated Show resolved Hide resolved
core/thread.py Outdated Show resolved Hide resolved
cogs/modmail.py Show resolved Hide resolved
@kyb3r
Copy link
Collaborator

kyb3r commented Jan 17, 2019

Update changelog, increment minor patch version, and then I will merge.

@Taaku18
Copy link
Collaborator Author

Taaku18 commented Jan 17, 2019

Update changelog, increment minor patch version, and then I will merge.

Ready to merge.

@kyb3r kyb3r merged commit 325ad1a into modmail-dev:master Jan 17, 2019
@Taaku18 Taaku18 deleted the dev branch January 19, 2019 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use config vars to store scheduled closure time
2 participants