Skip to content

Commit fc95df3

Browse files
authored
Remove update functionality and github commands. (#304)
* Remove autoupdate functionality * Remove update command * Remove github access token required * Update CHANGELOG.md * Remove github command
1 parent 45a23ec commit fc95df3

File tree

4 files changed

+10
-178
lines changed

4 files changed

+10
-178
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
# [Unreleased]
7+
# [Unreleased] (3.0.0)
88

99
### Added
1010

@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Threads will close automatically after some time when `thread_auto_close` is set.
1414
- Custom closing message can be set with `thread_auto_close_response`.
1515

16+
### Removed
17+
18+
- Removed autoupdate functionality and the `update` command in favour of the [Pull app](https://github.com/apps/pull).
19+
20+
Read more about updating your bot [here](https://github.com/kyb3r/modmail/wiki/updating)
21+
1622
### Changed
1723
- Channel names now can contain unicode characters.
1824
- Debug logs are now located in a unique file for each bot. (Internal change)

bot.py

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def __init__(self):
7474
self.plugin_db = PluginDatabaseClient(self)
7575

7676
self.metadata_task = self.loop.create_task(self.metadata_loop())
77-
self.autoupdate_task = self.loop.create_task(self.autoupdate_loop())
7877
self._load_extensions()
7978

8079
@property
@@ -192,11 +191,6 @@ def run(self, *args, **kwargs):
192191
self.loop.run_until_complete(self.metadata_task)
193192
except asyncio.CancelledError:
194193
logger.debug(info("data_task has been cancelled."))
195-
try:
196-
self.autoupdate_task.cancel()
197-
self.loop.run_until_complete(self.autoupdate_task)
198-
except asyncio.CancelledError:
199-
logger.debug(info("autoupdate_task has been cancelled."))
200194

201195
self.loop.run_until_complete(self.logout())
202196
for task in asyncio.Task.all_tasks():
@@ -904,62 +898,6 @@ async def validate_database_connection(self):
904898
else:
905899
logger.info(info("Successfully connected to the database."))
906900

907-
async def autoupdate_loop(self):
908-
await self.wait_until_ready()
909-
910-
if self.config.get("disable_autoupdates"):
911-
logger.warning(info("Autoupdates disabled."))
912-
logger.info(LINE)
913-
return
914-
915-
if not self.config.get("github_access_token"):
916-
logger.warning(info("GitHub access token not found."))
917-
logger.warning(info("Autoupdates disabled."))
918-
logger.info(LINE)
919-
return
920-
921-
logger.info(info("Autoupdate loop started."))
922-
923-
while not self.is_closed():
924-
changelog = await Changelog.from_url(self)
925-
latest = changelog.latest_version
926-
927-
if parse_version(self.version) < parse_version(latest.version):
928-
data = await self.api.update_repository()
929-
930-
embed = discord.Embed(color=discord.Color.green())
931-
932-
commit_data = data["data"]
933-
user = data["user"]
934-
embed.set_author(
935-
name=user["username"] + " - Updating Bot",
936-
icon_url=user["avatar_url"],
937-
url=user["url"],
938-
)
939-
940-
embed.set_footer(
941-
text=f"Updating Modmail v{self.version} " f"-> v{latest.version}"
942-
)
943-
944-
embed.description = latest.description
945-
for name, value in latest.fields.items():
946-
embed.add_field(name=name, value=value)
947-
948-
if commit_data:
949-
message = commit_data["commit"]["message"]
950-
html_url = commit_data["html_url"]
951-
short_sha = commit_data["sha"][:6]
952-
embed.add_field(
953-
name="Merge Commit",
954-
value=f"[`{short_sha}`]({html_url}) "
955-
f"{message} - {user['username']}",
956-
)
957-
logger.info(info("Bot has been updated."))
958-
channel = self.log_channel
959-
await channel.send(embed=embed)
960-
961-
await asyncio.sleep(3600)
962-
963901
async def metadata_loop(self):
964902
await self.wait_until_ready()
965903
if not self.guild:

cogs/utility.py

Lines changed: 2 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from core import checks
2424
from core.changelog import Changelog
25-
from core.decorators import github_access_token_required, trigger_typing
25+
from core.decorators import trigger_typing
2626
from core.models import InvalidConfigError, PermissionLevel
2727
from core.paginator import PaginatorSession, MessagePaginatorSession
2828
from core.utils import cleanup_code, info, error, User, get_perm_level
@@ -404,102 +404,7 @@ async def debug_clear(self, ctx):
404404
color=self.bot.main_color, description="Cached logs are now cleared."
405405
)
406406
)
407-
408-
@commands.command()
409-
@checks.has_permissions(PermissionLevel.OWNER)
410-
@github_access_token_required
411-
@trigger_typing
412-
async def github(self, ctx):
413-
"""Shows the GitHub user your Github_Access_Token is linked to."""
414-
data = await self.bot.api.get_user_info()
415-
416-
embed = Embed(
417-
title="GitHub", description="Current User", color=self.bot.main_color
418-
)
419-
user = data["user"]
420-
embed.set_author(
421-
name=user["username"], icon_url=user["avatar_url"], url=user["url"]
422-
)
423-
embed.set_thumbnail(url=user["avatar_url"])
424-
await ctx.send(embed=embed)
425-
426-
@commands.command()
427-
@checks.has_permissions(PermissionLevel.OWNER)
428-
@github_access_token_required
429-
@trigger_typing
430-
async def update(self, ctx, *, flag: str = ""):
431-
"""
432-
Update Modmail.
433-
434-
This only works for Heroku users who have configured their bot for updates.
435-
436-
To stay up-to-date with the latest commit
437-
from GitHub, specify "force" as the flag.
438-
"""
439-
440-
changelog = await Changelog.from_url(self.bot)
441-
latest = changelog.latest_version
442-
443-
desc = (
444-
f"The latest version is [`{self.bot.version}`]"
445-
"(https://github.com/kyb3r/modmail/blob/master/bot.py#L25)"
446-
)
447-
448-
if (
449-
parse_version(self.bot.version) >= parse_version(latest.version)
450-
and flag.lower() != "force"
451-
):
452-
embed = Embed(
453-
title="Already up to date", description=desc, color=self.bot.main_color
454-
)
455-
456-
data = await self.bot.api.get_user_info()
457-
if not data.get("error"):
458-
user = data["user"]
459-
embed.set_author(
460-
name=user["username"], icon_url=user["avatar_url"], url=user["url"]
461-
)
462-
else:
463-
data = await self.bot.api.update_repository()
464-
465-
commit_data = data["data"]
466-
user = data["user"]
467-
468-
if commit_data:
469-
embed = Embed(color=self.bot.main_color)
470-
471-
embed.set_footer(
472-
text=f"Updating Modmail v{self.bot.version} "
473-
f"-> v{latest.version}"
474-
)
475-
476-
embed.set_author(
477-
name=user["username"] + " - Updating bot",
478-
icon_url=user["avatar_url"],
479-
url=user["url"],
480-
)
481-
482-
embed.description = latest.description
483-
for name, value in latest.fields.items():
484-
embed.add_field(name=name, value=value)
485-
# message = commit_data['commit']['message']
486-
html_url = commit_data["html_url"]
487-
short_sha = commit_data["sha"][:6]
488-
embed.add_field(
489-
name="Merge Commit", value=f"[`{short_sha}`]({html_url})"
490-
)
491-
else:
492-
embed = Embed(
493-
title="Already up to date with master repository.",
494-
description="No further updates required",
495-
color=self.bot.main_color,
496-
)
497-
embed.set_author(
498-
name=user["username"], icon_url=user["avatar_url"], url=user["url"]
499-
)
500-
501-
return await ctx.send(embed=embed)
502-
407+
503408
@commands.command(aliases=["presence"])
504409
@checks.has_permissions(PermissionLevel.ADMINISTRATOR)
505410
async def activity(self, ctx, activity_type: str.lower, *, message: str = ""):

core/decorators.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,4 @@ async def wrapper(self, ctx: commands.Context, *args, **kwargs):
1010
await ctx.trigger_typing()
1111
return await func(self, ctx, *args, **kwargs)
1212

13-
return wrapper
14-
15-
16-
def github_access_token_required(func):
17-
@functools.wraps(func)
18-
async def wrapper(self, ctx: commands.Context, *args, **kwargs):
19-
if self.bot.config.get("github_access_token"):
20-
return await func(self, ctx, *args, **kwargs)
21-
22-
desc = (
23-
"You can only use this command if you have a "
24-
"configured `GITHUB_ACCESS_TOKEN`. Get a "
25-
"personal access token from developer settings."
26-
)
27-
embed = Embed(color=Color.red(), title="Unauthorized", description=desc)
28-
await ctx.send(embed=embed)
29-
30-
return wrapper
13+
return wrapper

0 commit comments

Comments
 (0)