|
22 | 22 | SOFTWARE. |
23 | 23 | """ |
24 | 24 |
|
25 | | -__version__ = '2.16.0' |
| 25 | +__version__ = '2.17.1' |
26 | 26 |
|
27 | 27 | import asyncio |
28 | 28 | import logging |
@@ -392,25 +392,23 @@ async def on_ready(self): |
392 | 392 | datetime.utcnow()).total_seconds() |
393 | 393 | if after < 0: |
394 | 394 | after = 0 |
395 | | - recipient = self.get_user(int(recipient_id)) |
396 | 395 |
|
397 | | - thread = await self.threads.find(recipient=recipient) |
| 396 | + thread = await self.threads.find(recipient_id=int(recipient_id)) |
398 | 397 |
|
399 | 398 | if not thread: |
400 | | - # If the recipient is gone or channel is deleted |
| 399 | + # If the channel is deleted |
401 | 400 | self.config.closures.pop(str(recipient_id)) |
402 | 401 | await self.config.update() |
403 | 402 | continue |
404 | 403 |
|
405 | | - # TODO: Low priority, |
406 | | - # Retrieve messages/replies when bot is down, from history? |
407 | 404 | await thread.close( |
408 | 405 | closer=self.get_user(items['closer_id']), |
409 | 406 | after=after, |
410 | 407 | silent=items['silent'], |
411 | 408 | delete_channel=items['delete_channel'], |
412 | 409 | message=items['message'] |
413 | 410 | ) |
| 411 | + |
414 | 412 | logger.info(LINE) |
415 | 413 |
|
416 | 414 | async def convert_emoji(self, name): |
@@ -605,7 +603,10 @@ async def on_message(self, message): |
605 | 603 |
|
606 | 604 | thread = await self.threads.find(channel=ctx.channel) |
607 | 605 | if thread is not None: |
608 | | - await self.api.append_log(message, type_='internal') |
| 606 | + if self.config.get('reply_without_command'): |
| 607 | + await thread.reply(message) |
| 608 | + else: |
| 609 | + await self.api.append_log(message, type_='internal') |
609 | 610 | elif ctx.invoked_with: |
610 | 611 | exc = commands.CommandNotFound( |
611 | 612 | 'Command "{}" is not found'.format(ctx.invoked_with) |
@@ -698,6 +699,24 @@ async def on_guild_channel_delete(self, channel): |
698 | 699 | return |
699 | 700 |
|
700 | 701 | await thread.close(closer=mod, silent=True, delete_channel=False) |
| 702 | + |
| 703 | + async def on_member_remove(self, member): |
| 704 | + thread = await self.threads.find(recipient=member) |
| 705 | + if thread: |
| 706 | + em = discord.Embed( |
| 707 | + description='The recipient has left the server.', |
| 708 | + color=discord.Color.red() |
| 709 | + ) |
| 710 | + await thread.channel.send(embed=em) |
| 711 | + |
| 712 | + async def on_member_join(self, member): |
| 713 | + thread = await self.threads.find(recipient=member) |
| 714 | + if thread: |
| 715 | + em = discord.Embed( |
| 716 | + description='The recipient has joined the server.', |
| 717 | + color=self.mod_color |
| 718 | + ) |
| 719 | + await thread.channel.send(embed=em) |
701 | 720 |
|
702 | 721 | async def on_message_delete(self, message): |
703 | 722 | """Support for deleting linked messages""" |
@@ -742,6 +761,8 @@ async def on_command_error(self, context, exception): |
742 | 761 | command=str(context.command)) |
743 | 762 | elif isinstance(exception, commands.CommandNotFound): |
744 | 763 | logger.warning(error('CommandNotFound: ' + str(exception))) |
| 764 | + elif isinstance(exception, commands.CheckFailure): |
| 765 | + logger.warning(error('CheckFailure: ' + str(exception))) |
745 | 766 | else: |
746 | 767 | logger.error(error('Unexpected exception:'), exc_info=exception) |
747 | 768 |
|
@@ -830,5 +851,5 @@ async def autoupdate_loop(self): |
830 | 851 | if os.name != 'nt': |
831 | 852 | import uvloop |
832 | 853 | uvloop.install() |
833 | | - bot = ModmailBot() # pylint: disable=invalid-name |
| 854 | + bot = ModmailBot() |
834 | 855 | bot.run() |
0 commit comments