Skip to content

Commit 7026147

Browse files
committed
Merge branch 'development'
2 parents 4ecff8a + 3105235 commit 7026147

File tree

6 files changed

+47
-15
lines changed

6 files changed

+47
-15
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
77
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.
88

9+
# v3.9.2
10+
11+
### Improved
12+
13+
- Additional HostingMethods (i.e. DOCKER, PM2, SCREEN). Autoupdates are now disabled on all docker instances. ([GH #2977](https://github.com/kyb3r/modmail/issues/2977), [PR #2988](https://github.com/kyb3r/modmail/pull/2988))
14+
15+
### Fixed
16+
17+
- `user_typing` default in the config help is now correct.
18+
919
# v3.9.1
1020

1121
### Internal

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM python:3.7-alpine
2+
ENV USING_DOCKER yes
23
WORKDIR /modmailbot
34
COPY . /modmailbot
45
RUN export PIP_NO_CACHE_DIR=false \

bot.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.9.1"
1+
__version__ = "3.9.2"
22

33

44
import asyncio
@@ -109,6 +109,18 @@ def hosting_method(self) -> HostingMethod:
109109
if os.environ.get("pm_id"):
110110
return HostingMethod.PM2
111111

112+
if os.environ.get("INVOCATION_ID"):
113+
return HostingMethod.SYSTEMD
114+
115+
if os.environ.get("USING_DOCKER"):
116+
return HostingMethod.DOCKER
117+
118+
if os.environ.get("INVOCATION_ID"):
119+
return HostingMethod.SYSTEMD
120+
121+
if os.environ.get("TERM"):
122+
return HostingMethod.SCREEN
123+
112124
return HostingMethod.OTHER
113125

114126
def startup(self):
@@ -242,39 +254,41 @@ def _cancel_tasks():
242254
if not tasks:
243255
return
244256

245-
logger.info('Cleaning up after %d tasks.', len(tasks))
257+
logger.info("Cleaning up after %d tasks.", len(tasks))
246258
for task in tasks:
247259
task.cancel()
248260

249261
loop.run_until_complete(asyncio.gather(*tasks, return_exceptions=True))
250-
logger.info('All tasks finished cancelling.')
262+
logger.info("All tasks finished cancelling.")
251263

252264
for task in tasks:
253265
if task.cancelled():
254266
continue
255267
if task.exception() is not None:
256-
loop.call_exception_handler({
257-
'message': 'Unhandled exception during Client.run shutdown.',
258-
'exception': task.exception(),
259-
'task': task
260-
})
268+
loop.call_exception_handler(
269+
{
270+
"message": "Unhandled exception during Client.run shutdown.",
271+
"exception": task.exception(),
272+
"task": task,
273+
}
274+
)
261275

262276
future = asyncio.ensure_future(runner(), loop=loop)
263277
future.add_done_callback(stop_loop_on_completion)
264278
try:
265279
loop.run_forever()
266280
except KeyboardInterrupt:
267-
logger.info('Received signal to terminate bot and event loop.')
281+
logger.info("Received signal to terminate bot and event loop.")
268282
finally:
269283
future.remove_done_callback(stop_loop_on_completion)
270-
logger.info('Cleaning up tasks.')
284+
logger.info("Cleaning up tasks.")
271285

272286
try:
273287
_cancel_tasks()
274288
if sys.version_info >= (3, 6):
275289
loop.run_until_complete(loop.shutdown_asyncgens())
276290
finally:
277-
logger.info('Closing the event loop.')
291+
logger.info("Closing the event loop.")
278292
loop.close()
279293

280294
if not future.cancelled():
@@ -1635,7 +1649,7 @@ async def autoupdate(self):
16351649
elif res != "Already up to date.":
16361650
logger.info("Bot has been updated.")
16371651
channel = self.update_channel
1638-
if self.hosting_method == HostingMethod.PM2:
1652+
if self.hosting_method in (HostingMethod.PM2, HostingMethod.SYSTEMD):
16391653
embed = discord.Embed(title="Bot has been updated", color=self.main_color)
16401654
embed.set_footer(
16411655
text=f"Updating Modmail v{self.version} " f"-> v{latest.version}"
@@ -1663,6 +1677,10 @@ async def before_autoupdate(self):
16631677
logger.warning("Autoupdates disabled.")
16641678
self.autoupdate_loop.cancel()
16651679

1680+
if self.hosting_method == HostingMethod.DOCKER:
1681+
logger.warning("Autoupdates disabled as using Docker.")
1682+
self.autoupdate_loop.cancel()
1683+
16661684
if not self.config.get("github_token") and self.hosting_method == HostingMethod.HEROKU:
16671685
logger.warning("GitHub access token not found.")
16681686
logger.warning("Autoupdates disabled.")

core/config_help.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"thumbnail": "https://placehold.it/100/e74c3c?text=+"
8787
},
8888
"user_typing": {
89-
"default": "Disabled",
89+
"default": "Enabled",
9090
"description": "When this is set to `yes`, whenever the recipient user starts to type in their DM channel, the moderator will see “{bot.user.display_name} is typing…” in the thread channel.",
9191
"examples": [
9292
"`{prefix}config set user_typing yes`",

core/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,7 @@ class DMDisabled(IntEnum):
276276
class HostingMethod(IntEnum):
277277
HEROKU = 0
278278
PM2 = 1
279-
OTHER = 2
279+
SYSTEMD = 2
280+
SCREEN = 3
281+
DOCKER = 4
282+
OTHER = 5

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exclude = '''
2121

2222
[tool.poetry]
2323
name = 'Modmail'
24-
version = '3.9.1'
24+
version = '3.9.2'
2525
description = "Modmail is similar to Reddit's Modmail, both in functionality and purpose. It serves as a shared inbox for server staff to communicate with their users in a seamless way."
2626
license = 'AGPL-3.0-only'
2727
authors = [

0 commit comments

Comments
 (0)