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