Skip to content

Commit b2089ee

Browse files
authored
Merge branch 'master' into plugin
2 parents 27d0fd5 + 8812bef commit b2089ee

16 files changed

+1913
-175
lines changed

.pylintrc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ disable=raw-checker-failed,
7171
metaclass-assignment,
7272
missing-docstring, # No doc-string
7373
no-name-in-module, # No name 'file' in module 'core'
74+
fixme,
75+
too-many-public-methods,
76+
too-many-locals,
77+
too-many-statements,
78+
too-many-branches,
79+
too-many-instance-attributes,
80+
too-many-arguments,
81+
too-few-public-methods,
82+
too-many-lines
7483

7584

7685
# Enable the message, report, category or checker with the given id(s). You can
@@ -356,7 +365,8 @@ good-names=i,
356365
id,
357366
db,
358367
f,
359-
dt
368+
dt,
369+
c
360370

361371
# Include a hint for the correct naming format with invalid-name.
362372
include-naming-hint=yes

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ 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+
# v2.12.5
8+
9+
### Fixed
10+
11+
- `config del` command will now work properly on selfhosted db bots.
12+
13+
14+
# v2.12.4
15+
16+
### Added
17+
- Named colors are now supported! Over 900 different common color names are recognized. A list of color names can be found in [core/_color_data.py](https://github.com/kyb3r/modmail/blob/master/core/_color_data.py).
18+
- Named colors can be set the same way as hex. But this can only be done through `?config set`, which means database modifications will not work.
19+
- For example: `?config set main_color yellowish green`.
20+
- New config var `main_color` allows you to customize the main Modmail color (as requested by many). Defaults to Discord `blurple`.
21+
22+
# v2.12.3
23+
24+
### Fixed
25+
- Patched a bug where `?logs` sub-commands were accessible by anyone.
26+
- Patched a bug where an error was raised if there was an open thread where the recipient had left the server.
27+
28+
Huge thanks to Sasiko for reporting these issues.
29+
730
# v2.12.2
831

932
### Fixed
@@ -25,6 +48,7 @@ In the future, the Modmail API (https://modmail.tk) will be deprecated. This is
2548
- A lot of painful code cleanup, which is good for us (the devs), but shouldn't affect you.
2649
- The appearance of the `logs` command. Should be clearer with better info now.
2750
- Bot owners get access to all commands regardless of server permissions.
51+
- Blocked users no longer receive a message, only the blocked emoji will be sent.
2852

2953
### Added
3054

README.md

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,69 @@
11
<div align="center">
2-
<img src='https://i.imgur.com/o558Qnq.png' align='center'>
3-
<br>
4-
<strong><i>A simple and functional Modmail bot for Discord.</i></strong>
5-
<br>
6-
<br>
7-
8-
9-
<a href="https://heroku.com/deploy?template=https://github.com/kyb3r/modmail">
10-
<img src="https://img.shields.io/badge/deploy_to-heroku-997FBC.svg?style=for-the-badge" />
11-
</a>
12-
13-
14-
<a href="https://discord.gg/j5e9p8w">
15-
<img src="https://img.shields.io/discord/515071617815019520.svg?style=for-the-badge&colorB=7289DA" alt="Support" />
16-
</a>
17-
18-
19-
20-
<a href="https://github.com/kyb3r/modmail/">
21-
<img src="https://api.modmail.tk/badges/instances.svg" alt="Bot instances" />
22-
</a>
23-
2+
<img src="https://i.imgur.com/o558Qnq.png" align="center">
3+
<br>
4+
<strong><i>A simple and functional Modmail bot for Discord.</i></strong>
5+
<br>
6+
<br>
7+
8+
<a href="https://heroku.com/deploy?template=https://github.com/kyb3r/modmail">
9+
<img src="https://img.shields.io/badge/deploy_to-heroku-997FBC.svg?style=for-the-badge">
10+
</a>
11+
12+
<a href="https://discord.gg/j5e9p8w">
13+
<img src="https://img.shields.io/discord/515071617815019520.svg?style=for-the-badge&colorB=7289DA" alt="Support">
14+
</a>
15+
16+
<a href="https://github.com/kyb3r/modmail/">
17+
<img src="https://api.modmail.tk/badges/instances.svg" alt="Bot instances">
18+
</a>
19+
20+
<a href="https://patreon.com/kyber">
21+
<img src="https://img.shields.io/badge/patreon-donate-orange.svg?style=for-the-badge" alt="Python 3.7">
22+
</a>
23+
24+
<a href="https://github.com/kyb3r/modmail/blob/master/LICENSE">
25+
<img src="https://img.shields.io/badge/license-mit-e74c3c.svg?style=for-the-badge" alt="MIT License">
26+
</a>
27+
</div>
2428

25-
<a href="https://patreon.com/kyber">
26-
<img src="https://img.shields.io/badge/patreon-donate-orange.svg?style=for-the-badge" alt="Python 3.7" />
27-
</a>
29+
---
2830

31+
## How Does Modmail Work?
2932

30-
<a href="https://github.com/kyb3r/modmail/blob/master/LICENSE">
31-
<img src="https://img.shields.io/badge/license-mit-e74c3c.svg?style=for-the-badge" alt="MIT License" />
32-
</a>
33+
<img src="https://i.imgur.com/GGukNDs.png" align="right" height="350">
3334

34-
</div>
35-
<br>
35+
When a user sends a direct message to the bot, a channel is created within an isolated category. This channel is where messages will be relayed. To reply to the message, simply use the command `?reply` in the channel. A full list of commands can be found in the [wiki](https://github.com/kyb3r/modmail/wiki) or by using the `?help` command.
3636

37-
## How does it work?
37+
## Installation
3838

39+
Currently, the easiest and fastest way to set up the bot is by using Heroku, which is a service that offers a free plan for hosting applications. If you choose to install the bot using Heroku, you will not need to download anything. The [**installation guide**](https://github.com/kyb3r/modmail/wiki/Installation) will guide you through the entire installation process. If you run into any problems, join our [Discord server](https://discord.gg/etJNHCQ) for help and support. Even if you don't have any issues, you should come and check out our awesome Discord community! :wink:
3940

40-
<img src='https://i.imgur.com/GGukNDs.png' align='right' height=300>
41+
---
4142

42-
When a user sends a direct message to the bot, a channel is created within an isolated category. This channel is where messages will be relayed. To reply to the message, simply use the command `reply` in the channel. See a full list of commands in the [wiki](https://github.com/kyb3r/modmail/wiki).
43+
# Notable Features
4344

45+
## Customizability
4446

45-
## Installation
47+
Modmail has a range of configuration variables that you can dynamically alter with the `?config` command. You can use them to change the different aspects of the bot, for example, the embed color, responses, reactions, status, etc. Snippets and custom command aliases are also supported. Snippets are shortcuts for predefined messages that you can send. Add or remove snippets with the `?snippets` command. The level of customization is ever growing thanks to our exceptional contributors.
4648

47-
Currently the easiest and fastest way to set up the bot is using Heroku which is a service that offers a free plan for hosting applications. If you choose to install the bot using Heroku, you will not need to download anything. Read the **[installation guide](https://github.com/kyb3r/modmail/wiki/Installation)**. If you ran into any problems, join our [discord server](https://discord.gg/etJNHCQ) for help and support. Even if you don't have any issues, you should come and check out our awesome Discord community! :wink:
49+
## Linked Messages
4850

49-
## Notable Features
51+
<img src="https://i.imgur.com/6L9aaNw.png" align="right" height="350">
5052

53+
Have you sent something with the `?reply` command by accident? Don't fret, you can delete your original message, and the bot will automatically delete the corresponding message sent to the recipient of the thread! You can also use the `?edit` command to edit a message you sent.
5154

52-
### Customizability
53-
There is a range of config variables you can dynamically change with the `config` command to change the appearance of the bot. For example embed color, responses, reactions, status etc. Snippets and custom command aliases are also supported, snippets are shortcuts for predefined messages that you can send. Add and remove snippets with the `snippets` command. The list of things you can change is ever growing thanks to the community for code contributions.
55+
## Thread Logs
5456

55-
### Linked Messages
56-
<img src='https://i.imgur.com/6L9aaNw.png' height=300 align='right'></img>
57+
Thread conversations are automatically logged with a generated viewable website of the complete thread. Logs are rendered with styled HTML and presented in an aesthetically pleasing way—it blends seamlessly with the mobile version of Discord. An example of a logged conversation: https://logs.modmail.tk/02032d65a6f3
5758

58-
Did you accidentally send something you didn't mean to with the `reply` command? Don't fret, if you delete the original message on your side, this bot automatically deletes the corresponding message that was sent to the recipient of the thread! This also works when you use the `edit` command to edit a message you have sent.
59+
## Automatic Updates
5960

60-
### Thread Logs
61+
The bot checks for new updates every hour and will automatically update to the newest version. Modmail is under active development, which means that you can always look forward to new and useful features! To disable this functionality, for example, when you customized your fork, you can do so by adding a `disable_autoupdates` config variable and set it to `yes` or `true`.
6162

62-
Thread conversations are automatically logged and a log link is provided with each thread. Logs are rendered with HTML and are presented in an aesthetically pleasing way, exactly like on discord, this especially integrates seamlessly with the mobile version of discord. Here's a link to an [example](https://logs.modmail.tk/02032d65a6f3).
63+
---
6364

64-
### Automatic Updates
65-
The bot checks for new updates every hour and automatically updates to a newer version if found. This bot is under active development so you can always look forward to new, useful features! If you do not want this functionality, for example, if you want to make changes to your fork, you can do so by adding a `disable_autoupdates` config variable.
65+
# Contributing
6666

67-
## Contributing
68-
This project is licenced under MIT. If you have ideas for commands create an issue or pull request. Contributions are always welcome, whether it be documentation improvements or new functionality, please feel free to create a pull request.
67+
This project is licenced under MIT. If you have any new ideas, create an issue or a pull request. Contributions to Modmail are always welcome, whether it be improvements to the documentation or new functionality, please feel free make the change.
6968

7069
If you use Modmail and love it, consider supporting me on **[Patreon](https://www.patreon.com/kyber)** :heart:

bot.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
SOFTWARE.
2323
"""
2424

25-
__version__ = '2.12.2'
25+
__version__ = '2.12.5'
2626

2727
import asyncio
2828
import os
@@ -126,7 +126,10 @@ def _load_extensions(self):
126126
continue
127127
cog = f'cogs.{file[:-3]}'
128128
print(Fore.CYAN + f'Loading {cog}' + Style.RESET_ALL)
129-
self.load_extension(cog)
129+
try:
130+
self.load_extension(cog)
131+
except Exception:
132+
print(f'Failed to load {cog}')
130133

131134
async def is_owner(self, user):
132135
allowed = {int(x) for x in
@@ -239,6 +242,19 @@ def recipient_color(self):
239242
else:
240243
return color
241244

245+
@property
246+
def main_color(self):
247+
color = self.config.get('main_color')
248+
if not color:
249+
return discord.Color.blurple()
250+
try:
251+
color = int(color.lstrip('#'), base=16)
252+
except ValueError:
253+
print('Invalid main_color provided')
254+
return discord.Color.blurple()
255+
else:
256+
return color
257+
242258
async def on_connect(self):
243259
print(LINE)
244260
print(Fore.CYAN, end='')
@@ -485,13 +501,13 @@ async def on_guild_channel_delete(self, channel):
485501
return
486502

487503
if not isinstance(channel, discord.TextChannel):
488-
if self.config.get('main_category_id') == channel.id:
504+
if int(self.config.get('main_category_id')) == channel.id:
489505
await self.config.update({
490506
'main_category_id': None
491507
})
492508
return
493509

494-
if self.config.get('log_channel_id') == channel.id:
510+
if int(self.config.get('log_channel_id')) == channel.id:
495511
await self.config.update({
496512
'log_channel_id': None
497513
})
@@ -637,6 +653,8 @@ async def autoupdate_loop(self):
637653
if self.self_hosted and not self.config.get('github_access_token'):
638654
print('Github access token not found.')
639655
print(Fore.CYAN + 'Autoupdates disabled.' + Style.RESET_ALL)
656+
print('GitHub access token not found.')
657+
print('Autoupdates disabled.')
640658
print(LINE)
641659
return
642660

@@ -656,7 +674,7 @@ async def autoupdate_loop(self):
656674
embed.set_footer(text=f"Updating Modmail v{self.version} "
657675
f"-> v{metadata['latest_version']}")
658676

659-
changelog = await ChangeLog.from_repo(self)
677+
changelog = await Changelog.from_url(self)
660678
latest = changelog.latest_version
661679
embed.description = latest.description
662680
for name, value in latest.fields.items():

0 commit comments

Comments
 (0)