|
1 |
| -__version__ = "3.7.6" |
| 1 | +__version__ = "3.7.7" |
2 | 2 |
|
3 | 3 |
|
4 | 4 | import asyncio
|
|
38 | 38 | from core.models import (
|
39 | 39 | DMDisabled,
|
40 | 40 | HostingMethod,
|
| 41 | + InvalidConfigError, |
41 | 42 | PermissionLevel,
|
42 | 43 | SafeFormatter,
|
43 | 44 | configure_logging,
|
@@ -633,32 +634,33 @@ def check_guild_age(self, author: discord.Member) -> bool:
|
633 | 634 | return True
|
634 | 635 |
|
635 | 636 | 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 | + ) |
638 | 654 |
|
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) |
647 | 655 | 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 |
662 | 664 |
|
663 | 665 | return True
|
664 | 666 |
|
@@ -1477,6 +1479,12 @@ async def autoupdate(self):
|
1477 | 1479 | channel = self.log_channel
|
1478 | 1480 | await channel.send(embed=embed)
|
1479 | 1481 | else:
|
| 1482 | + try: |
| 1483 | + # update fork if gh_token exists |
| 1484 | + await self.api.update_repository() |
| 1485 | + except InvalidConfigError: |
| 1486 | + pass |
| 1487 | + |
1480 | 1488 | command = "git pull"
|
1481 | 1489 | proc = await asyncio.create_subprocess_shell(command, stderr=PIPE, stdout=PIPE,)
|
1482 | 1490 | err = await proc.stderr.read()
|
|
0 commit comments