Skip to content

Commit 99f5175

Browse files
committed
Update fork even if not heroku, skip blocked roles
1 parent 36cad44 commit 99f5175

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
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.7.7
10+
11+
### Added
12+
13+
- Added updating github fork if GITHUB_TOKEN was provided
14+
15+
### Fixed
16+
17+
- Skip blocked roles check if user is not in main guild
18+
919
# v3.7.6
1020

1121
### Fixed

bot.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.7.6"
1+
__version__ = "3.7.7"
22

33

44
import asyncio
@@ -38,6 +38,7 @@
3838
from core.models import (
3939
DMDisabled,
4040
HostingMethod,
41+
InvalidConfigError,
4142
PermissionLevel,
4243
SafeFormatter,
4344
configure_logging,
@@ -633,32 +634,33 @@ def check_guild_age(self, author: discord.Member) -> bool:
633634
return True
634635

635636
def check_manual_blocked_roles(self, author: discord.Member) -> bool:
636-
for r in author.roles:
637-
if str(r.id) in self.blocked_roles:
637+
if isinstance(author, discord.Member):
638+
for r in author.roles:
639+
if str(r.id) in self.blocked_roles:
640+
641+
blocked_reason = self.blocked_roles.get(str(r.id)) or ""
642+
now = datetime.utcnow()
643+
644+
# etc "blah blah blah... until 2019-10-14T21:12:45.559948."
645+
end_time = re.search(r"until ([^`]+?)\.$", blocked_reason)
646+
if end_time is None:
647+
# backwards compat
648+
end_time = re.search(r"%([^%]+?)%", blocked_reason)
649+
if end_time is not None:
650+
logger.warning(
651+
r"Deprecated time message for user %s, block and unblock again to update.",
652+
author.name,
653+
)
638654

639-
blocked_reason = self.blocked_roles.get(str(r.id)) or ""
640-
now = datetime.utcnow()
641-
642-
# etc "blah blah blah... until 2019-10-14T21:12:45.559948."
643-
end_time = re.search(r"until ([^`]+?)\.$", blocked_reason)
644-
if end_time is None:
645-
# backwards compat
646-
end_time = re.search(r"%([^%]+?)%", blocked_reason)
647655
if end_time is not None:
648-
logger.warning(
649-
r"Deprecated time message for user %s, block and unblock again to update.",
650-
author.name,
651-
)
652-
653-
if end_time is not None:
654-
after = (datetime.fromisoformat(end_time.group(1)) - now).total_seconds()
655-
if after <= 0:
656-
# No longer blocked
657-
self.blocked_users.pop(str(author.id))
658-
logger.debug("No longer blocked, user %s.", author.name)
659-
return True
660-
logger.debug("User blocked, user %s.", author.name)
661-
return False
656+
after = (datetime.fromisoformat(end_time.group(1)) - now).total_seconds()
657+
if after <= 0:
658+
# No longer blocked
659+
self.blocked_users.pop(str(author.id))
660+
logger.debug("No longer blocked, user %s.", author.name)
661+
return True
662+
logger.debug("User blocked, user %s.", author.name)
663+
return False
662664

663665
return True
664666

@@ -1477,6 +1479,12 @@ async def autoupdate(self):
14771479
channel = self.log_channel
14781480
await channel.send(embed=embed)
14791481
else:
1482+
try:
1483+
# update fork if gh_token exists
1484+
await self.api.update_repository()
1485+
except InvalidConfigError:
1486+
pass
1487+
14801488
command = "git pull"
14811489
proc = await asyncio.create_subprocess_shell(command, stderr=PIPE, stdout=PIPE,)
14821490
err = await proc.stderr.read()

cogs/utility.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,11 +1913,18 @@ async def update(self, ctx, *, flag: str = ""):
19131913
description="No further updates required",
19141914
color=self.bot.main_color,
19151915
)
1916+
embed.set_footer(text="Force update")
19161917
embed.set_author(
19171918
name=user["username"], icon_url=user["avatar_url"], url=user["url"]
19181919
)
19191920
await ctx.send(embed=embed)
19201921
else:
1922+
# update fork if gh_token exists
1923+
try:
1924+
await self.bot.api.update_repository()
1925+
except InvalidConfigError:
1926+
pass
1927+
19211928
command = "git pull"
19221929

19231930
proc = await asyncio.create_subprocess_shell(command, stderr=PIPE, stdout=PIPE,)
@@ -1954,6 +1961,7 @@ async def update(self, ctx, *, flag: str = ""):
19541961
embed = discord.Embed(
19551962
title="Already up to date", description=desc, color=self.bot.main_color,
19561963
)
1964+
embed.set_footer(text="Force update")
19571965
await ctx.send(embed=embed)
19581966

19591967
@commands.command(hidden=True, name="eval")

0 commit comments

Comments
 (0)