瀏覽代碼

Errors now beep in console. Squelching video preview logs

main
Rocketsoup 1 月之前
父節點
當前提交
c664c0520c
共有 2 個檔案被更改,包括 12 行新增12 行删除
  1. 2
    2
      rocketbot/bot.py
  2. 10
    10
      rocketbot/cogs/videopreviewcog.py

+ 2
- 2
rocketbot/bot.py 查看文件

@@ -24,7 +24,7 @@ class Rocketbot(commands.Bot):
24 24
 		self.__first_ready = True
25 25
 
26 26
 	async def on_command_error(self, context: commands.Context, exception: BaseException) -> None:
27
-		bot_log(None, None, 'Command error')
27
+		bot_log(None, None, '\u0007Command error')
28 28
 		dump_stacktrace(exception)
29 29
 		if context.guild is None or \
30 30
 				context.message.channel is None or \
@@ -42,7 +42,7 @@ class Rocketbot(commands.Bot):
42 42
 		# Stack trace everything else
43 43
 
44 44
 	async def on_error(self, event_method, args=None, kwargs=None):
45
-		bot_log(None, None, 'Event caused error\n' + \
45
+		bot_log(None, None, '\u0007Event caused error\n' + \
46 46
 			f'	event method: {event_method}' + \
47 47
 			f'	event args: {args}' + \
48 48
 			f'	event kwargs: {kwargs}' + \

+ 10
- 10
rocketbot/cogs/videopreviewcog.py 查看文件

@@ -154,11 +154,11 @@ class VideoPreviewCog(BaseCog, name='Video Link Previews'):
154 154
 		delay: timedelta = self.get_guild_setting(message.guild, Self.SETTING_DELAY)
155 155
 		await asyncio.sleep(delay.total_seconds())
156 156
 		# Look for embeds already showing the video
157
-		self.log(message.guild, "Checking message for embeds")
157
+		# self.log(message.guild, "Checking message for embeds")
158 158
 		for embed in message.embeds:
159 159
 			if embed.video.url:
160 160
 				# If there's any video, skip downloading any previews
161
-				self.log(message.guild, "Message already has a video. Skipping this message.")
161
+				# self.log(message.guild, "Message already has a video. Skipping this message.")
162 162
 				return
163 163
 		await self._fetch_previews(message, links)
164 164
 
@@ -181,25 +181,25 @@ class VideoPreviewCog(BaseCog, name='Video Link Previews'):
181 181
 			universal_newlines=True
182 182
 		)
183 183
 		if result.returncode != 0:
184
-			self.log(message.guild, "Fetching link info JSON failed. Skipping preview.")
185
-			self.log(message.guild, result.stderr)
184
+			# self.log(message.guild, "Fetching link info JSON failed. Skipping preview.")
185
+			# self.log(message.guild, result.stderr)
186 186
 			return
187 187
 		try:
188 188
 			info: dict = json.loads(result.stdout)
189 189
 		except Exception as e:
190
-			self.log(message.guild, f"Error parsing info.json. Skipping preview. {e}")
190
+			# self.log(message.guild, f"Error parsing info.json. Skipping preview. {e}")
191 191
 			return
192 192
 		description = info.get('description') or ''
193 193
 		formats: list[dict] = info.get('formats') or []
194
-		self.log(message.guild, f"Found {len(formats)} formats")
194
+		# self.log(message.guild, f"Found {len(formats)} formats")
195 195
 		formats = list(filter(filter_video_format, formats))
196
-		self.log(message.guild, f"Filtered to {len(formats)} formats")
196
+		# self.log(message.guild, f"Filtered to {len(formats)} formats")
197 197
 		sorted_formats: list[dict] = sorted(formats, key=rank_video_format, reverse=True)
198 198
 		if len(sorted_formats) == 0:
199
-			self.log(message.guild, f"No eligible formats for URL {link.url}")
199
+			# self.log(message.guild, f"No eligible formats for URL {link.url}")
200 200
 			return
201 201
 		best_format: dict = sorted_formats[0]
202
-		self.log(message.guild, f"Best format is id {best_format.get('format_id')}")
202
+		# self.log(message.guild, f"Best format is id {best_format.get('format_id')}")
203 203
 		video_url: str = best_format.get('url')
204 204
 		link_description: str = "video"
205 205
 		if (best_format.get('width') or 0) > 0 and (best_format.get('height') or 0) > 0:
@@ -208,7 +208,7 @@ class VideoPreviewCog(BaseCog, name='Video Link Previews'):
208 208
 			link_description += f", {format_bytes(best_format.get('filesize'))}"
209 209
 		elif (best_format.get('filesize_approx') or 0) > 0:
210 210
 			link_description += f", {format_bytes(best_format.get('filesize_approx'))}"
211
-		content = "Hmm, video preview didn't load. Let's try this."
211
+		content = "Here's a preview of that video link."
212 212
 		if len(description) > 0:
213 213
 			content += "\n\n" + blockquote_markdown(suppress_markdown_url_previews(description)) + "\n"
214 214
 		if link.spoiler:

Loading…
取消
儲存