Skip to content

Commit 0c9c129

Browse files
committed
Formatting
1 parent c00e6be commit 0c9c129

File tree

5 files changed

+23
-35
lines changed

5 files changed

+23
-35
lines changed

bot.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,9 +1264,7 @@ async def handle_reaction_events(self, payload):
12641264
if not thread:
12651265
return
12661266
try:
1267-
_, *linked_message = await thread.find_linked_messages(
1268-
message.id, either_direction=True
1269-
)
1267+
_, *linked_message = await thread.find_linked_messages(message.id, either_direction=True)
12701268
except ValueError as e:
12711269
logger.warning("Failed to find linked message for reactions: %s", e)
12721270
return
@@ -1287,10 +1285,7 @@ async def handle_reaction_events(self, payload):
12871285
async def handle_react_to_contact(self, payload):
12881286
react_message_id = tryint(self.config.get("react_to_contact_message"))
12891287
react_message_emoji = self.config.get("react_to_contact_emoji")
1290-
if (
1291-
not all((react_message_id, react_message_emoji))
1292-
or payload.message_id != react_message_id
1293-
):
1288+
if not all((react_message_id, react_message_emoji)) or payload.message_id != react_message_id:
12941289
return
12951290
if payload.emoji.is_unicode_emoji():
12961291
emoji_fmt = payload.emoji.name
@@ -1314,7 +1309,8 @@ async def handle_react_to_contact(self, payload):
13141309
description=self.config["disabled_new_thread_response"],
13151310
)
13161311
embed.set_footer(
1317-
text=self.config["disabled_new_thread_footer"], icon_url=self.guild.icon_url,
1312+
text=self.config["disabled_new_thread_footer"],
1313+
icon_url=self.guild.icon_url,
13181314
)
13191315
logger.info(
13201316
"A new thread using react to contact was blocked from %s due to disabled Modmail.",
@@ -1327,7 +1323,8 @@ async def handle_react_to_contact(self, payload):
13271323

13281324
async def on_raw_reaction_add(self, payload):
13291325
await asyncio.gather(
1330-
self.handle_reaction_events(payload), self.handle_react_to_contact(payload),
1326+
self.handle_reaction_events(payload),
1327+
self.handle_react_to_contact(payload),
13311328
)
13321329

13331330
async def on_raw_reaction_remove(self, payload):

cogs/modmail.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,10 @@ async def contact(
10671067
return await ctx.send(embed=embed)
10681068

10691069
thread = await self.bot.threads.create(
1070-
recipient=user, creator=creator, category=category, manual_trigger=manual_trigger,
1070+
recipient=user,
1071+
creator=creator,
1072+
category=category,
1073+
manual_trigger=manual_trigger,
10711074
)
10721075
if thread.cancelled:
10731076
return

core/models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ def format(self, record):
127127

128128
def configure_logging(name, level=None):
129129
global ch_debug, log_level
130-
ch_debug = RotatingFileHandler(
131-
name, mode="a+", maxBytes=48000, backupCount=1, encoding="utf-8"
132-
)
130+
ch_debug = RotatingFileHandler(name, mode="a+", maxBytes=48000, backupCount=1, encoding="utf-8")
133131

134132
formatter_debug = FileFormatter(
135133
"%(asctime)s %(name)s[%(lineno)d] - %(levelname)s: %(message)s",

core/thread.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,11 @@ def cancelled(self, flag: bool):
111111
i.cancel()
112112

113113
@classmethod
114-
async def from_channel(
115-
cls, manager: "ThreadManager", channel: discord.TextChannel
116-
) -> "Thread":
114+
async def from_channel(cls, manager: "ThreadManager", channel: discord.TextChannel) -> "Thread":
117115
recipient_id = match_user_id(
118116
channel.topic
119117
) # there is a chance it grabs from another recipient's main thread
120-
recipient = manager.bot.get_user(recipient_id) or await manager.bot.fetch_user(
121-
recipient_id
122-
)
118+
recipient = manager.bot.get_user(recipient_id) or await manager.bot.fetch_user(recipient_id)
123119

124120
other_recipients = match_other_recipients(channel.topic)
125121
for n, uid in enumerate(other_recipients):
@@ -761,7 +757,11 @@ async def reply(self, message: discord.Message, anonymous: bool = False, plain:
761757
for user in self.recipients:
762758
user_msg_tasks.append(
763759
self.send(
764-
message, destination=user, from_mod=True, anonymous=anonymous, plain=plain,
760+
message,
761+
destination=user,
762+
from_mod=True,
763+
anonymous=anonymous,
764+
plain=plain,
765765
)
766766
)
767767

@@ -1071,19 +1071,15 @@ async def set_title(self, title: str) -> None:
10711071
user_id = match_user_id(self.channel.topic)
10721072
ids = ",".join(i.id for i in self._other_recipients)
10731073

1074-
await self.channel.edit(
1075-
topic=f"Title: {title}\nUser ID: {user_id}\nOther Recipients: {ids}"
1076-
)
1074+
await self.channel.edit(topic=f"Title: {title}\nUser ID: {user_id}\nOther Recipients: {ids}")
10771075

10781076
async def add_user(self, user: typing.Union[discord.Member, discord.User]) -> None:
10791077
title = match_title(self.channel.topic)
10801078
user_id = match_user_id(self.channel.topic)
10811079
self._other_recipients.append(user)
10821080

10831081
ids = ",".join(str(i.id) for i in self._other_recipients)
1084-
await self.channel.edit(
1085-
topic=f"Title: {title}\nUser ID: {user_id}\nOther Recipients: {ids}"
1086-
)
1082+
await self.channel.edit(topic=f"Title: {title}\nUser ID: {user_id}\nOther Recipients: {ids}")
10871083

10881084

10891085
class ThreadManager:
@@ -1139,9 +1135,7 @@ async def find(
11391135
if not thread.cancelled and (
11401136
not thread.channel or not self.bot.get_channel(thread.channel.id)
11411137
):
1142-
logger.warning(
1143-
"Found existing thread for %s but the channel is invalid.", recipient_id
1144-
)
1138+
logger.warning("Found existing thread for %s but the channel is invalid.", recipient_id)
11451139
await thread.close(closer=self.bot.user, silent=True, delete_channel=False)
11461140
thread = None
11471141
else:
@@ -1280,9 +1274,7 @@ async def create(
12801274
if str(r.emoji) == deny_emoji:
12811275
thread.cancelled = True
12821276
self.bot.loop.create_task(
1283-
destination.send(
1284-
embed=discord.Embed(title="Cancelled", color=self.bot.error_color)
1285-
)
1277+
destination.send(embed=discord.Embed(title="Cancelled", color=self.bot.error_color))
12861278
)
12871279

12881280
async def remove_reactions():

core/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,7 @@ def cleanup_code(content: str) -> str:
218218
return content.strip("` \n")
219219

220220

221-
TOPIC_OTHER_RECIPIENTS_REGEX = re.compile(
222-
r"Other Recipients:\s*((?:\d{17,21},*)+)", flags=re.IGNORECASE
223-
)
221+
TOPIC_OTHER_RECIPIENTS_REGEX = re.compile(r"Other Recipients:\s*((?:\d{17,21},*)+)", flags=re.IGNORECASE)
224222
TOPIC_TITLE_REGEX = re.compile(r"\bTitle: (.*)\n(?:User ID: )\b", flags=re.IGNORECASE | re.DOTALL)
225223
TOPIC_UID_REGEX = re.compile(r"\bUser ID:\s*(\d{17,21})\b", flags=re.IGNORECASE)
226224

0 commit comments

Comments
 (0)