reformat/refactor
This commit is contained in:
		| @@ -52,6 +52,7 @@ class Util: | |||||||
|                     resp = await request.json() |                     resp = await request.json() | ||||||
|                     return resp.get("count") |                     return resp.get("count") | ||||||
|         except Exception as e: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return False |             return False | ||||||
|  |  | ||||||
| @@ -79,7 +80,8 @@ class Util: | |||||||
|                 ) as request: |                 ) as request: | ||||||
|                     resp: dict = await request.json() |                     resp: dict = await request.json() | ||||||
|                     return resp |                     return resp | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return None |             return None | ||||||
|  |  | ||||||
| @@ -120,7 +122,7 @@ class Util: | |||||||
|         Returns: |         Returns: | ||||||
|             bool |             bool | ||||||
|         """ |         """ | ||||||
|         if not flag in [0, 1]: |         if flag not in [0, 1]: | ||||||
|             return False |             return False | ||||||
|  |  | ||||||
|         reqObj: dict = { |         reqObj: dict = { | ||||||
| @@ -142,7 +144,8 @@ class Util: | |||||||
|                 ) as request: |                 ) as request: | ||||||
|                     result = await request.json() |                     result = await request.json() | ||||||
|                     return result.get("success", False) |                     return result.get("success", False) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return False |             return False | ||||||
|  |  | ||||||
| @@ -155,7 +158,7 @@ class Util: | |||||||
|         Returns: |         Returns: | ||||||
|             bool |             bool | ||||||
|         """ |         """ | ||||||
|         if not user_id in self.timers: |         if user_id not in self.timers: | ||||||
|             return True |             return True | ||||||
|         now = int(time.time()) |         now = int(time.time()) | ||||||
|         if (now - self.timers[user_id]) < self.karma_cooldown: |         if (now - self.timers[user_id]) < self.karma_cooldown: | ||||||
| @@ -183,7 +186,8 @@ class Karma(commands.Cog): | |||||||
|  |  | ||||||
|         try: |         try: | ||||||
|             self.update_karma_chan.start() |             self.update_karma_chan.start() | ||||||
|         except Exception as e: |         except:  # noqa | ||||||
|  |             """Safe to ignore""" | ||||||
|             pass |             pass | ||||||
|  |  | ||||||
|     @tasks.loop(seconds=30, reconnect=True) |     @tasks.loop(seconds=30, reconnect=True) | ||||||
| @@ -199,7 +203,8 @@ class Karma(commands.Cog): | |||||||
|                 embed=top_embed, |                 embed=top_embed, | ||||||
|                 content="## This message will automatically update periodically.", |                 content="## This message will automatically update periodically.", | ||||||
|             ) |             ) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|  |  | ||||||
|     @commands.Cog.listener() |     @commands.Cog.listener() | ||||||
| @@ -228,7 +233,7 @@ class Karma(commands.Cog): | |||||||
|             return |             return | ||||||
|         if not message.guild: |         if not message.guild: | ||||||
|             return |             return | ||||||
|         if not message.guild.id in [ |         if message.guild.id not in [ | ||||||
|             1145182936002482196, |             1145182936002482196, | ||||||
|             1228740575235149855, |             1228740575235149855, | ||||||
|         ]:  # Not a valid guild for cmd |         ]:  # Not a valid guild for cmd | ||||||
| @@ -251,7 +256,8 @@ class Karma(commands.Cog): | |||||||
|                 display: str = guild_member.display_name |                 display: str = guild_member.display_name | ||||||
|                 message_content = message_content.replace(mention[0], display) |                 message_content = message_content.replace(mention[0], display) | ||||||
|                 logging.debug("New message: %s", message_content) |                 logging.debug("New message: %s", message_content) | ||||||
|             except: |             except Exception as e: | ||||||
|  |                 logging.debug("Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|  |  | ||||||
|         message_content = discord.utils.escape_markdown(message_content) |         message_content = discord.utils.escape_markdown(message_content) | ||||||
| @@ -264,7 +270,7 @@ class Karma(commands.Cog): | |||||||
|  |  | ||||||
|         flooding: bool = not await self.util.check_cooldown(message.author.id) |         flooding: bool = not await self.util.check_cooldown(message.author.id) | ||||||
|         exempt_uids: list[int] = [1172340700663255091, 992437729927376996] |         exempt_uids: list[int] = [1172340700663255091, 992437729927376996] | ||||||
|         if flooding and not message.author.id in exempt_uids: |         if flooding and message.author.id not in exempt_uids: | ||||||
|             return await message.add_reaction(emoji="❗") |             return await message.add_reaction(emoji="❗") | ||||||
|  |  | ||||||
|         processed_keywords_lc: list[str] = [] |         processed_keywords_lc: list[str] = [] | ||||||
| @@ -330,7 +336,8 @@ class Karma(commands.Cog): | |||||||
|                         return |                         return | ||||||
|                     display = guild_member.display_name |                     display = guild_member.display_name | ||||||
|                     keyword = keyword.replace(mention[0], display) |                     keyword = keyword.replace(mention[0], display) | ||||||
|                 except: |                 except Exception as e: | ||||||
|  |                     logging.debug("Exception: %s", str(e)) | ||||||
|                     traceback.print_exc() |                     traceback.print_exc() | ||||||
|                     continue |                     continue | ||||||
|  |  | ||||||
| @@ -347,7 +354,7 @@ class Karma(commands.Cog): | |||||||
|     def cog_unload(self) -> None: |     def cog_unload(self) -> None: | ||||||
|         try: |         try: | ||||||
|             self.update_karma_chan.cancel() |             self.update_karma_chan.cancel() | ||||||
|         except: |         except:  # noqa | ||||||
|             """Safe to ignore""" |             """Safe to ignore""" | ||||||
|             pass |             pass | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										80
									
								
								cogs/meme.py
									
									
									
									
									
								
							
							
						
						
									
										80
									
								
								cogs/meme.py
									
									
									
									
									
								
							| @@ -180,10 +180,11 @@ class Meme(commands.Cog): | |||||||
|  |  | ||||||
|         def predicate(ctx): |         def predicate(ctx): | ||||||
|             try: |             try: | ||||||
|                 if not ctx.channel.id in BOT_CHANIDS: |                 if ctx.channel.id not in BOT_CHANIDS: | ||||||
|                     logging.debug("%s not found in %s", ctx.channel.id, BOT_CHANIDS) |                     logging.debug("%s not found in %s", ctx.channel.id, BOT_CHANIDS) | ||||||
|                 return ctx.channel.id in BOT_CHANIDS |                 return ctx.channel.id in BOT_CHANIDS | ||||||
|             except: |             except Exception as e: | ||||||
|  |                 logging.debug("Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|                 return False |                 return False | ||||||
|  |  | ||||||
| @@ -198,7 +199,7 @@ class Meme(commands.Cog): | |||||||
|                 None |                 None | ||||||
|         """ |         """ | ||||||
|  |  | ||||||
|         if not uid in self.meme_leaderboard: |         if uid not in self.meme_leaderboard: | ||||||
|             self.meme_leaderboard[uid] = 1 |             self.meme_leaderboard[uid] = 1 | ||||||
|         else: |         else: | ||||||
|             self.meme_leaderboard[uid] += 1 |             self.meme_leaderboard[uid] += 1 | ||||||
| @@ -211,11 +212,13 @@ class Meme(commands.Cog): | |||||||
|             query_2_params: tuple = (uid, self.meme_leaderboard[uid]) |             query_2_params: tuple = (uid, self.meme_leaderboard[uid]) | ||||||
|             try: |             try: | ||||||
|                 await db_conn.execute(query_1, query_1_params) |                 await db_conn.execute(query_1, query_1_params) | ||||||
|             except: |             except:  # noqa | ||||||
|  |                 """Safe to ignore""" | ||||||
|                 pass |                 pass | ||||||
|             try: |             try: | ||||||
|                 await db_conn.execute(query_2, query_2_params) |                 await db_conn.execute(query_2, query_2_params) | ||||||
|             except: |             except:  # noqa | ||||||
|  |                 """Safe to ignore""" | ||||||
|                 pass |                 pass | ||||||
|             await db_conn.commit() |             await db_conn.commit() | ||||||
|         try: |         try: | ||||||
| @@ -273,26 +276,29 @@ class Meme(commands.Cog): | |||||||
|             try: |             try: | ||||||
|                 try: |                 try: | ||||||
|                     explosm_comics = await explosm_grabber.get() |                     explosm_comics = await explosm_grabber.get() | ||||||
|                 except: |                 except:  # noqa | ||||||
|  |                     """Safe to ignore""" | ||||||
|                     pass |                     pass | ||||||
|                 try: |                 try: | ||||||
|                     xkcd_comics = await xkcd_grabber.get() |                     xkcd_comics = await xkcd_grabber.get() | ||||||
|                 except: |                 except:  # noqa | ||||||
|  |                     """Safe to ignore""" | ||||||
|                     pass |                     pass | ||||||
|                 try: |                 try: | ||||||
|                     smbc_comics = await smbc_grabber.get() |                     smbc_comics = await smbc_grabber.get() | ||||||
|                 except: |                 except:  # noqa | ||||||
|  |                     """Safe to ignore""" | ||||||
|                     pass |                     pass | ||||||
|                 try: |                 try: | ||||||
|                     qc_comics = await qc_grabber.get() |                     qc_comics = await qc_grabber.get() | ||||||
|                     print(f"QC: {qc_comics}") |                     print(f"QC: {qc_comics}") | ||||||
|                 except: |                 except:  # noqa | ||||||
|  |                     """Safe to ignore""" | ||||||
|                     pass |                     pass | ||||||
|                 try: |                 try: | ||||||
|                     dino_comics = await dino_grabber.get() |                     dino_comics = await dino_grabber.get() | ||||||
|                 except Exception as e: |                 except Exception as e: | ||||||
|                     logging.debug("Dino failed: %s", str(e)) |                     logging.debug("Dino failed: %s", str(e)) | ||||||
|                     pass |  | ||||||
|                 try: |                 try: | ||||||
|                     onions = await onion_grabber.get() |                     onions = await onion_grabber.get() | ||||||
|                 except Exception as e: |                 except Exception as e: | ||||||
| @@ -303,7 +309,8 @@ class Meme(commands.Cog): | |||||||
|                 except Exception as e: |                 except Exception as e: | ||||||
|                     logging.debug("THNs failed: %s", str(e)) |                     logging.debug("THNs failed: %s", str(e)) | ||||||
|                     pass |                     pass | ||||||
|             except: |             except Exception as e: | ||||||
|  |                 logging.debug("Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|             agents: list[str] = constants.HTTP_UA_LIST |             agents: list[str] = constants.HTTP_UA_LIST | ||||||
|             headers: dict = {"User-Agent": random.choice(agents)} |             headers: dict = {"User-Agent": random.choice(agents)} | ||||||
| @@ -335,7 +342,8 @@ class Meme(commands.Cog): | |||||||
|                                     username="r/memes", |                                     username="r/memes", | ||||||
|                                 ) |                                 ) | ||||||
|                         await asyncio.sleep(2) |                         await asyncio.sleep(2) | ||||||
|                 except: |                 except:  # noqa | ||||||
|  |                     """Safe to ignore""" | ||||||
|                     pass |                     pass | ||||||
|             try: |             try: | ||||||
|                 for comic in explosm_comics: |                 for comic in explosm_comics: | ||||||
| @@ -371,7 +379,8 @@ class Meme(commands.Cog): | |||||||
|                                 thread=thread, |                                 thread=thread, | ||||||
|                             ) |                             ) | ||||||
|                         await asyncio.sleep(2) |                         await asyncio.sleep(2) | ||||||
|             except: |             except:  # noqa | ||||||
|  |                 """Safe to ignore""" | ||||||
|                 pass |                 pass | ||||||
|             try: |             try: | ||||||
|                 for comic in xkcd_comics: |                 for comic in xkcd_comics: | ||||||
| @@ -406,7 +415,8 @@ class Meme(commands.Cog): | |||||||
|                                 thread=thread, |                                 thread=thread, | ||||||
|                             ) |                             ) | ||||||
|                         await asyncio.sleep(2) |                         await asyncio.sleep(2) | ||||||
|             except: |             except:  # noqa | ||||||
|  |                 """Safe to ignore""" | ||||||
|                 pass |                 pass | ||||||
|             try: |             try: | ||||||
|                 for comic in smbc_comics: |                 for comic in smbc_comics: | ||||||
| @@ -440,7 +450,8 @@ class Meme(commands.Cog): | |||||||
|                                 thread=thread, |                                 thread=thread, | ||||||
|                             ) |                             ) | ||||||
|                         await asyncio.sleep(2) |                         await asyncio.sleep(2) | ||||||
|             except: |             except:  # noqa | ||||||
|  |                 """Safe to ignore""" | ||||||
|                 pass |                 pass | ||||||
|             try: |             try: | ||||||
|                 for comic in qc_comics: |                 for comic in qc_comics: | ||||||
| @@ -477,9 +488,9 @@ class Meme(commands.Cog): | |||||||
|                                 thread=thread, |                                 thread=thread, | ||||||
|                             ) |                             ) | ||||||
|                     await asyncio.sleep(2) |                     await asyncio.sleep(2) | ||||||
|             except: |             except Exception as e: | ||||||
|  |                 logging.debug("Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|                 pass |  | ||||||
|             try: |             try: | ||||||
|                 for comic in dino_comics: |                 for comic in dino_comics: | ||||||
|                     if not comic: |                     if not comic: | ||||||
| @@ -512,7 +523,8 @@ class Meme(commands.Cog): | |||||||
|                                 thread=thread, |                                 thread=thread, | ||||||
|                             ) |                             ) | ||||||
|                         await asyncio.sleep(2) |                         await asyncio.sleep(2) | ||||||
|             except: |             except:  # noqa | ||||||
|  |                 """Safe to ignore""" | ||||||
|                 pass |                 pass | ||||||
|             try: |             try: | ||||||
|                 for onion in onions: |                 for onion in onions: | ||||||
| @@ -537,7 +549,8 @@ class Meme(commands.Cog): | |||||||
|                             if onion_video: |                             if onion_video: | ||||||
|                                 await webhook.send(f"^ video: {onion_video}") |                                 await webhook.send(f"^ video: {onion_video}") | ||||||
|                         await asyncio.sleep(2) |                         await asyncio.sleep(2) | ||||||
|             except: |             except:  # noqa | ||||||
|  |                 """Safe to ignore""" | ||||||
|                 pass |                 pass | ||||||
|             try: |             try: | ||||||
|                 for thn in thns: |                 for thn in thns: | ||||||
| @@ -563,10 +576,11 @@ class Meme(commands.Cog): | |||||||
|                             if thn_video: |                             if thn_video: | ||||||
|                                 await webhook.send(f"^ video: {thn_video}") |                                 await webhook.send(f"^ video: {thn_video}") | ||||||
|                     await asyncio.sleep(2) |                     await asyncio.sleep(2) | ||||||
|             except: |             except:  # noqa | ||||||
|  |                 """Safe to ignore""" | ||||||
|                 pass |                 pass | ||||||
|         except: |         except Exception as e: | ||||||
|             # await self.bot.get_channel(self.MEMESTREAM_CHANID).send(f"FUCK, MY MEEMER!  YOU DENTED MY MEEMER!") |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|  |  | ||||||
|     @tasks.loop(hours=12.0) |     @tasks.loop(hours=12.0) | ||||||
| @@ -579,7 +593,8 @@ class Meme(commands.Cog): | |||||||
|                 return await self.do_autos(only_comics=True)  # Skip first iteration! |                 return await self.do_autos(only_comics=True)  # Skip first iteration! | ||||||
|  |  | ||||||
|             await self.do_autos() |             await self.do_autos() | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|  |  | ||||||
|     @tasks.loop(hours=0.5) |     @tasks.loop(hours=0.5) | ||||||
| @@ -588,7 +603,8 @@ class Meme(commands.Cog): | |||||||
|         try: |         try: | ||||||
|             await asyncio.sleep(10)  # Try to ensure we are ready first |             await asyncio.sleep(10)  # Try to ensure we are ready first | ||||||
|             await self.do_autos(only_comics=True) |             await self.do_autos(only_comics=True) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|  |  | ||||||
|     @bridge.bridge_command()  # type: ignore |     @bridge.bridge_command()  # type: ignore | ||||||
| @@ -604,9 +620,10 @@ class Meme(commands.Cog): | |||||||
|         try: |         try: | ||||||
|             await ctx.respond("Trying!", ephemeral=True) |             await ctx.respond("Trying!", ephemeral=True) | ||||||
|             await self.do_autos() |             await self.do_autos() | ||||||
|         except: |         except Exception as e: | ||||||
|             await ctx.respond("Fuck! :(", ephemeral=True) |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|  |             await ctx.respond("Fuck! :(", ephemeral=True) | ||||||
|  |  | ||||||
|     @bridge.bridge_command(hidden=True) |     @bridge.bridge_command(hidden=True) | ||||||
|     @commands.is_owner() |     @commands.is_owner() | ||||||
| @@ -615,9 +632,10 @@ class Meme(commands.Cog): | |||||||
|         try: |         try: | ||||||
|             await ctx.respond("Trying!", ephemeral=True) |             await ctx.respond("Trying!", ephemeral=True) | ||||||
|             await self.do_autos(only_comics=True) |             await self.do_autos(only_comics=True) | ||||||
|         except: |         except Exception as e: | ||||||
|             await ctx.respond("Fuck! :(", ephemeral=True) |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|  |             await ctx.respond("Fuck! :(", ephemeral=True) | ||||||
|  |  | ||||||
|     @commands.Cog.listener() |     @commands.Cog.listener() | ||||||
|     async def on_message(self, message: discord.Message) -> None: |     async def on_message(self, message: discord.Message) -> None: | ||||||
| @@ -688,7 +706,8 @@ class Meme(commands.Cog): | |||||||
|                 if not member: |                 if not member: | ||||||
|                     out_top.pop(x) |                     out_top.pop(x) | ||||||
|             return out_top[0 : (n + 1)] |             return out_top[0 : (n + 1)] | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return None |             return None | ||||||
|  |  | ||||||
| @@ -739,7 +758,8 @@ class Meme(commands.Cog): | |||||||
|                 embed=top_embed, |                 embed=top_embed, | ||||||
|                 content="## This message will automatically update periodically.", |                 content="## This message will automatically update periodically.", | ||||||
|             ) |             ) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|  |  | ||||||
|     @bridge.bridge_command(hidden=True) |     @bridge.bridge_command(hidden=True) | ||||||
|   | |||||||
							
								
								
									
										56
									
								
								cogs/misc.py
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								cogs/misc.py
									
									
									
									
									
								
							| @@ -6,7 +6,6 @@ import random | |||||||
| from typing import Optional | from typing import Optional | ||||||
| import logging | import logging | ||||||
| import discord | import discord | ||||||
| import aiosqlite as sqlite3 |  | ||||||
| from sh import cowsay as cow_say, fortune | from sh import cowsay as cow_say, fortune | ||||||
| from discord.ext import bridge, commands | from discord.ext import bridge, commands | ||||||
| from disc_havoc import Havoc | from disc_havoc import Havoc | ||||||
| @@ -67,10 +66,11 @@ class Misc(commands.Cog): | |||||||
|  |  | ||||||
|         def predicate(ctx): |         def predicate(ctx): | ||||||
|             try: |             try: | ||||||
|                 if not ctx.channel.id in BOT_CHANIDS: |                 if ctx.channel.id not in BOT_CHANIDS: | ||||||
|                     logging.debug("%s not found in %s", ctx.channel.id, BOT_CHANIDS) |                     logging.debug("%s not found in %s", ctx.channel.id, BOT_CHANIDS) | ||||||
|                 return ctx.channel.id in BOT_CHANIDS |                 return ctx.channel.id in BOT_CHANIDS | ||||||
|             except: |             except Exception as e: | ||||||
|  |                 logging.debug("Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|                 return False |                 return False | ||||||
|  |  | ||||||
| @@ -82,7 +82,7 @@ class Misc(commands.Cog): | |||||||
|         def predicate(ctx): |         def predicate(ctx): | ||||||
|             try: |             try: | ||||||
|                 if ( |                 if ( | ||||||
|                     not ctx.channel.id in BOT_CHANIDS |                     ctx.channel.id not in BOT_CHANIDS | ||||||
|                     and not ctx.channel.id == DRUGS_CHANID |                     and not ctx.channel.id == DRUGS_CHANID | ||||||
|                 ): |                 ): | ||||||
|                     logging.debug( |                     logging.debug( | ||||||
| @@ -92,7 +92,8 @@ class Misc(commands.Cog): | |||||||
|                         DRUGS_CHANID, |                         DRUGS_CHANID, | ||||||
|                     ) |                     ) | ||||||
|                 return ctx.channel.id in BOT_CHANIDS or ctx.channel.id == DRUGS_CHANID |                 return ctx.channel.id in BOT_CHANIDS or ctx.channel.id == DRUGS_CHANID | ||||||
|             except: |             except Exception as e: | ||||||
|  |                 logging.debug("Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|                 return False |                 return False | ||||||
|  |  | ||||||
| @@ -246,7 +247,7 @@ class Misc(commands.Cog): | |||||||
|                 return |                 return | ||||||
|             authorDisplay: str = ( |             authorDisplay: str = ( | ||||||
|                 ctx.author.display_name |                 ctx.author.display_name | ||||||
|                 if not (ctx.author.display_name is None) |                 if (ctx.author.display_name is not None) | ||||||
|                 else ctx.message.author.display_name |                 else ctx.message.author.display_name | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
| @@ -285,7 +286,7 @@ class Misc(commands.Cog): | |||||||
|         try: |         try: | ||||||
|             authorDisplay: str = ( |             authorDisplay: str = ( | ||||||
|                 ctx.author.display_name |                 ctx.author.display_name | ||||||
|                 if not (ctx.author.display_name is None) |                 if (ctx.author.display_name is not None) | ||||||
|                 else ctx.message.author.display_name |                 else ctx.message.author.display_name | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
| @@ -416,7 +417,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -456,7 +457,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -498,7 +499,7 @@ class Misc(commands.Cog): | |||||||
|  |  | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -571,7 +572,7 @@ class Misc(commands.Cog): | |||||||
|             if not cowfile: |             if not cowfile: | ||||||
|                 cowfile = random.choice(self.COWS).replace(".cow", "") |                 cowfile = random.choice(self.COWS).replace(".cow", "") | ||||||
|  |  | ||||||
|             if not f"{cowfile}.cow" in self.COWS: |             if f"{cowfile}.cow" not in self.COWS: | ||||||
|                 return await ctx.respond(f"Unknown cow {cowfile}, who dat?") |                 return await ctx.respond(f"Unknown cow {cowfile}, who dat?") | ||||||
|  |  | ||||||
|             fortune_said: str = str(fortune("-n1000", "-s")) |             fortune_said: str = str(fortune("-n1000", "-s")) | ||||||
| @@ -609,7 +610,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -656,7 +657,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -703,7 +704,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -751,7 +752,7 @@ class Misc(commands.Cog): | |||||||
|  |  | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -794,7 +795,7 @@ class Misc(commands.Cog): | |||||||
|         recipient_id: Optional[int] = None  # Used for mentions |         recipient_id: Optional[int] = None  # Used for mentions | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -847,7 +848,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -893,7 +894,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -933,7 +934,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay = ( |         authorDisplay = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -977,7 +978,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -1017,7 +1018,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -1057,7 +1058,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -1103,7 +1104,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -1151,7 +1152,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay = ( |         authorDisplay = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -1303,7 +1304,7 @@ class Misc(commands.Cog): | |||||||
|         """ |         """ | ||||||
|         authorDisplay: str = ( |         authorDisplay: str = ( | ||||||
|             ctx.author.display_name |             ctx.author.display_name | ||||||
|             if not (ctx.author.display_name is None) |             if (ctx.author.display_name is not None) | ||||||
|             else ctx.message.author.display_name |             else ctx.message.author.display_name | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
| @@ -1446,7 +1447,10 @@ class Misc(commands.Cog): | |||||||
|             )  # known: cannot react to interaction |             )  # known: cannot react to interaction | ||||||
|  |  | ||||||
|     def cog_unload(self) -> None: |     def cog_unload(self) -> None: | ||||||
|         """Run on Cog Unload""" |         """ | ||||||
|  |         Run on Cog Unload | ||||||
|  |         Not currently used. | ||||||
|  |         """ | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| import io | import io | ||||||
| import random | import random | ||||||
| import asyncio | import asyncio | ||||||
|  | import logging | ||||||
| import traceback | import traceback | ||||||
| from typing import Optional | from typing import Optional | ||||||
| import discord | import discord | ||||||
| @@ -32,7 +33,8 @@ class Owner(commands.Cog): | |||||||
|             return await ctx.respond("I am afraid I can't let you do that.") |             return await ctx.respond("I am afraid I can't let you do that.") | ||||||
|         try: |         try: | ||||||
|             _temperature: int = int(temp) |             _temperature: int = int(temp) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             return await ctx.respond("Invalid input") |             return await ctx.respond("Invalid input") | ||||||
|         if _temperature < -15: |         if _temperature < -15: | ||||||
|             return await ctx.respond("Too cold! (-15°C minimum)") |             return await ctx.respond("Too cold! (-15°C minimum)") | ||||||
| @@ -178,7 +180,8 @@ class Owner(commands.Cog): | |||||||
|             ) |             ) | ||||||
|             await message.delete() |             await message.delete() | ||||||
|             await ctx.respond("OK!", ephemeral=True) |             await ctx.respond("OK!", ephemeral=True) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return await ctx.respond("Failed! :(", ephemeral=True) |             return await ctx.respond("Failed! :(", ephemeral=True) | ||||||
|  |  | ||||||
| @@ -221,7 +224,8 @@ class Owner(commands.Cog): | |||||||
|             ) |             ) | ||||||
|             await message.delete() |             await message.delete() | ||||||
|             await ctx.respond("OK!", ephemeral=True) |             await ctx.respond("OK!", ephemeral=True) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return await ctx.respond("Failed! :(", ephemeral=True) |             return await ctx.respond("Failed! :(", ephemeral=True) | ||||||
|  |  | ||||||
| @@ -261,7 +265,8 @@ class Owner(commands.Cog): | |||||||
|             ) |             ) | ||||||
|             await message.delete() |             await message.delete() | ||||||
|             await ctx.respond("OK!", ephemeral=True) |             await ctx.respond("OK!", ephemeral=True) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return await ctx.respond("Failed! :(", ephemeral=True) |             return await ctx.respond("Failed! :(", ephemeral=True) | ||||||
|  |  | ||||||
| @@ -297,13 +302,14 @@ class Owner(commands.Cog): | |||||||
|                 str(role.name).lower() for role in member_roles |                 str(role.name).lower() for role in member_roles | ||||||
|             ] |             ] | ||||||
|             opers_chan: discord.TextChannel = ctx.guild.get_channel(1181416083287187546) |             opers_chan: discord.TextChannel = ctx.guild.get_channel(1181416083287187546) | ||||||
|             if not "einsperren" in member_role_names: |             if "einsperren" not in member_role_names: | ||||||
|                 try: |                 try: | ||||||
|                     if member.id in self.former_roles_store: |                     if member.id in self.former_roles_store: | ||||||
|                         self.former_roles_store.pop(member.id) |                         self.former_roles_store.pop(member.id) | ||||||
|                     self.former_roles_store[member.id] = member.roles |                     self.former_roles_store[member.id] = member.roles | ||||||
|                 except: |                 except:  # noqa | ||||||
|                     pass  # Safe to ignore |                     """Safe to ignore""" | ||||||
|  |                     pass | ||||||
|                 try: |                 try: | ||||||
|                     await member.edit(roles=[einsperren_role], reason=audit_reason) |                     await member.edit(roles=[einsperren_role], reason=audit_reason) | ||||||
|                     await ctx.respond( |                     await ctx.respond( | ||||||
| @@ -312,12 +318,13 @@ class Owner(commands.Cog): | |||||||
|                     await opers_chan.send( |                     await opers_chan.send( | ||||||
|                         f"@everyone: {ctx.user.display_name} gesendet {member_display} an einsperren." |                         f"@everyone: {ctx.user.display_name} gesendet {member_display} an einsperren." | ||||||
|                     ) |                     ) | ||||||
|                 except: |                 except Exception as e: | ||||||
|  |                     logging.debug("Exception: %s", str(e)) | ||||||
|                     traceback.print_exc() |                     traceback.print_exc() | ||||||
|                     return await ctx.respond("GOTTVERDAMMT!!", ephemeral=True) |                     return await ctx.respond("GOTTVERDAMMT!!", ephemeral=True) | ||||||
|                 self.former_roles_store[member.id] = member.roles |                 self.former_roles_store[member.id] = member.roles | ||||||
|  |  | ||||||
|             if not member.id in self.former_roles_store: |             if member.id not in self.former_roles_store: | ||||||
|                 await member.edit(roles=[])  # No roles |                 await member.edit(roles=[])  # No roles | ||||||
|             else: |             else: | ||||||
|                 former_roles: list = self.former_roles_store.get(member.id, [0]) |                 former_roles: list = self.former_roles_store.get(member.id, [0]) | ||||||
|   | |||||||
| @@ -36,7 +36,8 @@ class Radio(commands.Cog): | |||||||
|         def predicate(ctx): |         def predicate(ctx): | ||||||
|             try: |             try: | ||||||
|                 return ctx.channel.id == 1221615558492029050 |                 return ctx.channel.id == 1221615558492029050 | ||||||
|             except: |             except Exception as e: | ||||||
|  |                 logging.debug("Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|                 return False |                 return False | ||||||
|  |  | ||||||
| @@ -71,10 +72,11 @@ class Radio(commands.Cog): | |||||||
|                     logging.debug("Failed to cancel radio_state_loop: %s", str(e)) |                     logging.debug("Failed to cancel radio_state_loop: %s", str(e)) | ||||||
|                 self.radio_state_loop.start() |                 self.radio_state_loop.start() | ||||||
|                 logging.info("radio_state_loop task started!") |                 logging.info("radio_state_loop task started!") | ||||||
|             except: |             except Exception as e: | ||||||
|                 logging.critical("Could not start task...") |                 logging.critical("Could not start task... Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return |             return | ||||||
|  |  | ||||||
| @@ -85,8 +87,11 @@ class Radio(commands.Cog): | |||||||
|             (radio_guild, radio_chan) = self.channels["sfm"] |             (radio_guild, radio_chan) = self.channels["sfm"] | ||||||
|             try: |             try: | ||||||
|                 vc: discord.VoiceProtocol = self.bot.voice_clients[-1] |                 vc: discord.VoiceProtocol = self.bot.voice_clients[-1] | ||||||
|             except: |             except Exception as e: | ||||||
|                 logging.debug("No voice client, establishing new VC connection...") |                 logging.debug( | ||||||
|  |                     "No voice client, establishing new VC connection... (Exception: %s)", | ||||||
|  |                     str(e), | ||||||
|  |                 ) | ||||||
|                 guild: Optional[discord.Guild] = self.bot.get_guild(radio_guild) |                 guild: Optional[discord.Guild] = self.bot.get_guild(radio_guild) | ||||||
|                 if not guild: |                 if not guild: | ||||||
|                     return |                     return | ||||||
| @@ -105,8 +110,8 @@ class Radio(commands.Cog): | |||||||
|                 source: discord.FFmpegAudio = discord.FFmpegOpusAudio( |                 source: discord.FFmpegAudio = discord.FFmpegOpusAudio( | ||||||
|                     self.STREAM_URL, before_options="-timeout 3000000" |                     self.STREAM_URL, before_options="-timeout 3000000" | ||||||
|                 ) |                 ) | ||||||
|                 vc.play( |                 vc.play(  # type: ignore | ||||||
|                     source,  # type: ignore |                     source, | ||||||
|                     after=lambda e: logging.info("Error: %s", e) if e else None, |                     after=lambda e: logging.info("Error: %s", e) if e else None, | ||||||
|                 ) |                 ) | ||||||
|             # Get Now Playing |             # Get Now Playing | ||||||
| @@ -118,7 +123,8 @@ class Radio(commands.Cog): | |||||||
|                         type=discord.ActivityType.listening, name=np_track |                         type=discord.ActivityType.listening, name=np_track | ||||||
|                     ) |                     ) | ||||||
|                 ) |                 ) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|  |  | ||||||
|     @bridge.bridge_command() |     @bridge.bridge_command() | ||||||
|   | |||||||
| @@ -2,7 +2,6 @@ import traceback | |||||||
| import logging | import logging | ||||||
| from typing import Optional, Union | from typing import Optional, Union | ||||||
| from regex import Pattern | from regex import Pattern | ||||||
| import urllib |  | ||||||
| import discord | import discord | ||||||
| import regex | import regex | ||||||
| from util.sing_util import Utility | from util.sing_util import Utility | ||||||
| @@ -30,10 +29,11 @@ class Sing(commands.Cog): | |||||||
|  |  | ||||||
|         def predicate(ctx): |         def predicate(ctx): | ||||||
|             try: |             try: | ||||||
|                 if not ctx.channel.id in BOT_CHANIDS: |                 if ctx.channel.id not in BOT_CHANIDS: | ||||||
|                     logging.debug("%s not found in %s", ctx.channel.id, BOT_CHANIDS) |                     logging.debug("%s not found in %s", ctx.channel.id, BOT_CHANIDS) | ||||||
|                 return ctx.channel.id in BOT_CHANIDS |                 return ctx.channel.id in BOT_CHANIDS | ||||||
|             except: |             except Exception as e: | ||||||
|  |                 logging.debug("Exception: %s", str(e)) | ||||||
|                 traceback.print_exc() |                 traceback.print_exc() | ||||||
|                 return False |                 return False | ||||||
|  |  | ||||||
| @@ -103,7 +103,7 @@ class Sing(commands.Cog): | |||||||
|                 search_result_wrapped_short: list[str] = search_result[ |                 search_result_wrapped_short: list[str] = search_result[ | ||||||
|                     2 |                     2 | ||||||
|                 ]  # Third is short wrapped lyrics |                 ]  # Third is short wrapped lyrics | ||||||
|                 if not ctx.channel.id in BOT_CHANIDS: |                 if ctx.channel.id not in BOT_CHANIDS: | ||||||
|                     short_lyrics = " ".join( |                     short_lyrics = " ".join( | ||||||
|                         search_result_wrapped_short |                         search_result_wrapped_short | ||||||
|                     )  # Replace with shortened lyrics for non spamchans |                     )  # Replace with shortened lyrics for non spamchans | ||||||
|   | |||||||
| @@ -6,8 +6,6 @@ AI | |||||||
| class AIException(Exception): | class AIException(Exception): | ||||||
|     """AI Exception (generic)""" |     """AI Exception (generic)""" | ||||||
|  |  | ||||||
|     pass |  | ||||||
|  |  | ||||||
|  |  | ||||||
| """ | """ | ||||||
| LoveHate | LoveHate | ||||||
| @@ -17,8 +15,6 @@ LoveHate | |||||||
| class LoveHateException(Exception): | class LoveHateException(Exception): | ||||||
|     """Love Hate Exception (generic)""" |     """Love Hate Exception (generic)""" | ||||||
|  |  | ||||||
|     pass |  | ||||||
|  |  | ||||||
|  |  | ||||||
| """ | """ | ||||||
| Misc | Misc | ||||||
| @@ -27,5 +23,3 @@ Misc | |||||||
|  |  | ||||||
| class MiscException(Exception): | class MiscException(Exception): | ||||||
|     """Misc Exception (generic)""" |     """Misc Exception (generic)""" | ||||||
|  |  | ||||||
|     pass |  | ||||||
|   | |||||||
| @@ -65,7 +65,7 @@ class Havoc(bridge.Bot): | |||||||
|             load_method(f"cogs.{cog}") |             load_method(f"cogs.{cog}") | ||||||
|  |  | ||||||
|         importlib.reload(api) |         importlib.reload(api) | ||||||
|         from api import API |         from api import API  # noqa (voodoo) | ||||||
|  |  | ||||||
|         api_config = hypercorn.config.Config() |         api_config = hypercorn.config.Config() | ||||||
|         api_config.bind = ["127.0.0.1:5992"] |         api_config.bind = ["127.0.0.1:5992"] | ||||||
|   | |||||||
| @@ -79,11 +79,12 @@ class CatboxAsync: | |||||||
|                     ) as request: |                     ) as request: | ||||||
|                         request.raise_for_status() |                         request.raise_for_status() | ||||||
|                         return await request.text() |                         return await request.text() | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return None |             return None | ||||||
|         finally: |         finally: | ||||||
|             try: |             try: | ||||||
|                 fileContents.close() |                 fileContents.close() | ||||||
|             except: |             except:  # noqa | ||||||
|                 return None |                 return None | ||||||
|   | |||||||
| @@ -75,7 +75,7 @@ class JesusMemeGenerator: | |||||||
|                     logging.info("Meme upload failed!") |                     logging.info("Meme upload failed!") | ||||||
|                     return None |                     return None | ||||||
|                 return meme_link |                 return meme_link | ||||||
|         except: |         except Exception as e: | ||||||
|             print(traceback.format_exc()) |             logging.debug("Exception: %s", str(e)) | ||||||
|             pass |             traceback.print_exc() | ||||||
|         return None |         return None | ||||||
|   | |||||||
| @@ -94,12 +94,13 @@ class LitterboxAsync: | |||||||
|                 ) as request: |                 ) as request: | ||||||
|                     request.raise_for_status() |                     request.raise_for_status() | ||||||
|                     return await request.text() |                     return await request.text() | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return None |             return None | ||||||
|         finally: |         finally: | ||||||
|             if isinstance(file, BufferedReader): |             if isinstance(file, BufferedReader): | ||||||
|                 try: |                 try: | ||||||
|                     file.close() |                     file.close() | ||||||
|                 except: |                 except:  # noqa | ||||||
|                     return None |                     return None | ||||||
|   | |||||||
| @@ -149,7 +149,7 @@ class DB: | |||||||
|         Returns: |         Returns: | ||||||
|             str |             str | ||||||
|         """ |         """ | ||||||
|         if not flag in range(-1, 2): |         if flag not in range(-1, 2): | ||||||
|             raise LoveHateException( |             raise LoveHateException( | ||||||
|                 f"Invalid flag {flag} specified, is this love (1), hate (-1), or dontcare? (0)" |                 f"Invalid flag {flag} specified, is this love (1), hate (-1), or dontcare? (0)" | ||||||
|             ) |             ) | ||||||
|   | |||||||
| @@ -449,7 +449,8 @@ class Util: | |||||||
|                         if not fact: |                         if not fact: | ||||||
|                             raise BaseException("RandFact Src 1 Failed") |                             raise BaseException("RandFact Src 1 Failed") | ||||||
|                         return fact |                         return fact | ||||||
|                 except: |                 except Exception as e: | ||||||
|  |                     logging.debug("Exception: %s", str(e)) | ||||||
|                     async with await client.get( |                     async with await client.get( | ||||||
|                         facts_backup_url, timeout=ClientTimeout(connect=5, sock_read=5) |                         facts_backup_url, timeout=ClientTimeout(connect=5, sock_read=5) | ||||||
|                     ) as request: |                     ) as request: | ||||||
| @@ -502,7 +503,8 @@ class Util: | |||||||
|                 self.LAST_5_COFFEES.pop()  # Store no more than 5 of the last served coffees |                 self.LAST_5_COFFEES.pop()  # Store no more than 5 of the last served coffees | ||||||
|             self.LAST_5_COFFEES.append(randomCoffee) |             self.LAST_5_COFFEES.append(randomCoffee) | ||||||
|             return randomCoffee |             return randomCoffee | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return None |             return None | ||||||
|  |  | ||||||
|   | |||||||
| @@ -89,7 +89,8 @@ class Utility: | |||||||
|                     song.split(search_split_by)[2:] |                     song.split(search_split_by)[2:] | ||||||
|                 )  # Lyric text from split index 2 and beyond |                 )  # Lyric text from split index 2 and beyond | ||||||
|             return (search_artist, search_song, search_subsearch) |             return (search_artist, search_song, search_subsearch) | ||||||
|         except: |         except Exception as e: | ||||||
|  |             logging.debug("Exception: %s", str(e)) | ||||||
|             traceback.print_exc() |             traceback.print_exc() | ||||||
|             return False |             return False | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user