Skip to content

Commit fa8bc77

Browse files
committed
Add ability to disable message sent reactions
1 parent 231e1b4 commit fa8bc77

File tree

2 files changed

+52
-37
lines changed

2 files changed

+52
-37
lines changed

CHANGELOG.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ 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.13.13
8+
9+
### What's new?
10+
11+
Added the ability to disable the `sent_emoji` and `blocked_emoji` when a user messages modmail.
12+
13+
You can do this via `?config set sent_emoji disable`
14+
715
# v2.13.12
8-
### Added
16+
### What's new?
917

1018
Added image link in title in case discord fails to embed an image.
1119

1220
# v2.13.11
1321

14-
### Added
22+
### What's new?
1523
- Introduced a new configuration variable `account_age` for setting a minimum account creation age.
1624
- Users blocked by this reason will be stored in `blocked` along with other reasons for being blocked.
1725
- `account_age` needs to be an ISO-8601 Duration Format (examples: `P12DT3H` 12 days and 3 hours, `P3Y5M` 3 years and 5 months `PT4H14M999S` 4 hours 14 minutes and 999 seconds). https://en.wikipedia.org/wiki/ISO_8601#Durations.
@@ -42,7 +50,7 @@ Added image link in title in case discord fails to embed an image.
4250

4351
# v2.13.7
4452

45-
### Added
53+
### What's new?
4654
- The ability to enable typing interactions.
4755
- If you want the bot to type in the thread channel if the user is also typing, add the config variable `user_typing` and set it to "yes" or "true". use `config del` to disable the functionality. The same thing in reverse is also possible if you want the user to see the bot type when someone is typing in the thread channel add the `mod_typing` config variable.
4856
- New `status` command, change the bot's status to `online`, `idle`, `dnd`, `invisible`, or `offline`.
@@ -59,7 +67,7 @@ Added image link in title in case discord fails to embed an image.
5967

6068
# v2.13.5
6169

62-
### Added
70+
### What's new?
6371
- You will no longer need to view your bot debug logs from Heroku. `debug` will show you the recent logs within 24h through a series of embeds.
6472
- If you don't mind your data (may or may not be limited to: user ID, guild ID, bot name) be on the internet, `debug hastebin` will upload a formatted logs file to https://hasteb.in.
6573
- `debug clear` will clear the locally cached logs.
@@ -101,7 +109,7 @@ Added image link in title in case discord fails to embed an image.
101109

102110
# v2.13.0
103111

104-
### Added
112+
### What's new?
105113
- Plugins:
106114
- Think of it like addons! Anyone (with the skills) can create a plugin, make it public and distribute it. Add a welcome message to Modmail, or moderation commands? It's all up to your imagination! Have a niche feature request that you think only your server would benefit from? Plugins are your go-to!
107115
- [Creating Plugins Documentation](https://github.com/kyb3r/modmail/wiki/Plugins).
@@ -114,7 +122,7 @@ Added image link in title in case discord fails to embed an image.
114122

115123
# v2.12.4
116124

117-
### Added
125+
### What's new?
118126
- 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).
119127
- 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.
120128
- For example: `config set main_color yellowish green`.
@@ -151,7 +159,7 @@ We recommend using your own database for logs. In the future you will soon get a
151159
- Bot owners get access to all commands regardless of server permissions.
152160
- Blocked users no longer receive a message, only the blocked emoji will be sent.
153161

154-
### Added
162+
### What's new?
155163
- **Note:** The following commands only work if you are self-hosting your logs. We recommend you to use your own database.
156164
- Log search queries, in the form of two new commands.
157165
- `logs search [query]` - this searches all log messages for a query string.
@@ -164,7 +172,7 @@ We recommend using your own database for logs. In the future you will soon get a
164172

165173
# v2.11.0
166174

167-
### Added
175+
### What's new?
168176
- `loglink` command, returns the log link for the current thread.
169177

170178
# v2.10.2
@@ -179,7 +187,7 @@ We recommend using your own database for logs. In the future you will soon get a
179187

180188
# v2.10.0
181189

182-
### Added
190+
### What's new?
183191
- `anonreply` command to anonymously reply to the recipient.
184192
The username of the anonymous user defaults to the `mod_tag` (the footer text of a mod reply message). The avatar defaults the guild icon URL. However you can change both of these via the `anon_username`, `anon_avatar_url` and `anon_tag` config variables.
185193

@@ -196,7 +204,7 @@ The username of the anonymous user defaults to the `mod_tag` (the footer text of
196204
### Changed
197205
- Forgot to enable custom embed colors.
198206

199-
### Added
207+
### What's new?
200208
- Ability to set a custom `mod_tag` (the text in the footer of the mod reply embed, which by default says "Moderator")
201209

202210
# v2.9.2
@@ -208,7 +216,7 @@ The username of the anonymous user defaults to the `mod_tag` (the footer text of
208216
### Fixed
209217
- Bug where the close command wouldn't work if you didnt configure a log channel.
210218

211-
### Added
219+
### What's new?
212220
- Ability to set your own custom `mod_color` and `recipient_color` for the thread message embeds.
213221

214222
# v2.9.1
@@ -222,7 +230,7 @@ The username of the anonymous user defaults to the `mod_tag` (the footer text of
222230

223231
# v2.9.0
224232

225-
### Added
233+
### What's new?
226234
- New command `note` will add a system message to your thread logs. This is useful for noting the context of a conversation.
227235

228236
# v2.8.1
@@ -240,7 +248,7 @@ The username of the anonymous user defaults to the `mod_tag` (the footer text of
240248

241249
# v2.7.2
242250

243-
### Added
251+
### What's new?
244252
- `config options` command to see a list of valid config variables that you can modify.
245253

246254
### Security
@@ -285,7 +293,7 @@ Thread channels will now default to being private (`@everyone`'s read message pe
285293

286294
# v2.6.0
287295

288-
### Added
296+
### What's new?
289297
- `threads` is now a default alias to `logs`.
290298

291299
### Changed
@@ -335,7 +343,7 @@ Fixed a bug in activity command where it would fail to set the activity on bot r
335343

336344
# v2.4.2
337345

338-
### Added
346+
### What's new?
339347
- Ability to set your own Twitch URL for `streaming` activity status.
340348

341349
# v2.4.1
@@ -345,7 +353,7 @@ Fixed a bug in activity command where it would fail to set the activity on bot r
345353

346354
# v2.4.0
347355

348-
### Added
356+
### What's new?
349357
- Added the `activity` command for setting the activity
350358
- [PR #131](https://github.com/kyb3r/modmail/pull/131#issue-244686818) this supports multiple activity types (`playing`, `watching`, `listening` and `streaming`).
351359

@@ -355,7 +363,7 @@ Fixed a bug in activity command where it would fail to set the activity on bot r
355363

356364
# v2.3.0
357365

358-
### Added
366+
### What's new?
359367
- Ability to self-host logs.
360368

361369
### Changed
@@ -369,7 +377,7 @@ Fixed a bug in activity command where it would fail to set the activity on bot r
369377

370378
# v2.2.0
371379

372-
### Added
380+
### What's new?
373381
- Notify command `notify [role]`.
374382
- Notify a given role or yourself to the next thread message received.
375383
- Once a thread message is received you will be pinged once only.
@@ -388,7 +396,7 @@ Fixed a bug in activity command where it would fail to set the activity on bot r
388396

389397
# v2.1.0
390398

391-
### Added
399+
### What's new?
392400
- Ability to set a custom thread creation response message.
393401
- Via `config set thread_creation_response [message]`.
394402

@@ -406,7 +414,7 @@ Fixed a bug in activity command where it would fail to set the activity on bot r
406414

407415
# v2.0.9
408416

409-
### Added
417+
### What's new?
410418
- Support for custom blocked and sent emoji.
411419
- Use the `config set blocked_emoji [emoji]` or `sent_emoji` commands.
412420

@@ -416,7 +424,7 @@ Fixed a bug in activity command where it would fail to set the activity on bot r
416424

417425
# v2.0.8
418426

419-
### Added
427+
### What's new?
420428
- Added the ability to use your own log channel.
421429
- You can do this via the `config set log_channel_id <id>` command.
422430
- Added the ability to use your own main inbox category.
@@ -429,7 +437,7 @@ Fixed a bug in activity command where it would fail to set the activity on bot r
429437

430438
# v2.0.7
431439

432-
### Added
440+
### What's new?
433441
- Added a `changelog` command to view the bot's changelog within discord.
434442

435443
### Changed
@@ -493,7 +501,7 @@ Read the updated installation guide [here](https://github.com/kyb3r/modmail/wiki
493501
### Fixed
494502
- `status` command now changes playing status indefinitely.
495503

496-
### Added
504+
### What's new?
497505
- Dynamic `help` command (#84).
498506
- Dynamic configuration through `api.modmail.tk`.
499507
- Thread logs via `logs.modmail.tk` (#78).

bot.py

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

25-
__version__ = '2.13.12'
25+
__version__ = '2.13.13'
2626

2727
import asyncio
2828
import logging
@@ -440,27 +440,31 @@ async def retrieve_emoji(self):
440440
sent_emoji = self.config.get('sent_emoji', '✅')
441441
blocked_emoji = self.config.get('blocked_emoji', '🚫')
442442

443+
443444
if sent_emoji not in UNICODE_EMOJI:
444445
try:
445446
sent_emoji = await converter.convert(
446447
ctx, sent_emoji.strip(':')
447448
)
448449
except commands.BadArgument:
449-
logger.warning(info(f'Sent Emoji ({sent_emoji}) '
450-
f'is not a valid emoji.'))
451-
del self.config.cache['sent_emoji']
452-
await self.config.update()
450+
if sent_emoji != 'disable':
451+
logger.warning(info(f'Sent Emoji ({sent_emoji}) '
452+
f'is not a valid emoji.'))
453+
del self.config.cache['sent_emoji']
454+
await self.config.update()
453455

454456
if blocked_emoji not in UNICODE_EMOJI:
455457
try:
456458
blocked_emoji = await converter.convert(
457459
ctx, blocked_emoji.strip(':')
458460
)
459461
except commands.BadArgument:
460-
logger.warning(info(f'Blocked emoji ({blocked_emoji}) '
461-
'is not a valid emoji.'))
462-
del self.config.cache['blocked_emoji']
463-
await self.config.update()
462+
if blocked_emoji != 'disable':
463+
logger.warning(info(f'Blocked emoji ({blocked_emoji}) '
464+
'is not a valid emoji.'))
465+
del self.config.cache['blocked_emoji']
466+
await self.config.update()
467+
464468
return sent_emoji, blocked_emoji
465469

466470
async def process_modmail(self, message):
@@ -531,11 +535,12 @@ async def process_modmail(self, message):
531535
await self.config.update()
532536
else:
533537
reaction = sent_emoji
534-
535-
try:
536-
await message.add_reaction(reaction)
537-
except (discord.HTTPException, discord.InvalidArgument):
538-
pass
538+
539+
if reaction != 'disable':
540+
try:
541+
await message.add_reaction(reaction)
542+
except (discord.HTTPException, discord.InvalidArgument):
543+
pass
539544

540545
if str(message.author.id) not in self.blocked_users:
541546
thread = await self.threads.find_or_create(message.author)
@@ -615,6 +620,8 @@ async def on_message(self, message):
615620
self.dispatch('command_error', ctx, exc)
616621

617622
async def on_typing(self, channel, user, _):
623+
if user.bot:
624+
return
618625
if isinstance(channel, discord.DMChannel):
619626
if not self.config.get('user_typing'):
620627
return

0 commit comments

Comments
 (0)