Skip to content

Commit

Permalink
Merge pull request #343 from PyBotDevs/add-activity-logger
Browse files Browse the repository at this point in the history
Add isobot server activity logger
  • Loading branch information
notsniped authored Mar 22, 2024
2 parents f1dc302 + 6c41080 commit 5913ecb
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,46 @@ async def on_ready():

@client.event
async def on_message(ctx):
"""This event is fired whenever a message is sent (in a readable channel)"""
currency.new_wallet(ctx.author.id)
currency.new_bank(ctx.author.id)
create_isocoin_key(ctx.author.id)
userdata.generate(ctx.author.id)
settings.generate(ctx.author.id)
items.generate(ctx.author.id)
levelling.generate(ctx.author.id)
automod.generate(ctx.guild.id)
uList = list()
presence = _presence.get_raw()
if str(ctx.guild.id) in presence:
for userid in presence[str(ctx.guild.id)].keys(): uList.append(userid)
else: pass
for user in uList:
if user in ctx.content and not ctx.author.bot:
fetch_user = client.get_user(id(user))
await ctx.channel.send(f"{fetch_user.display_name} went AFK <t:{floor(presence[str(ctx.guild.id)][str(user)]['time'])}:R>: {presence[str(ctx.guild.id)][str(user)]['response']}")
if str(ctx.guild.id) in presence and str(ctx.author.id) in presence[str(ctx.guild.id)]:
_presence.remove_afk(ctx.guild.id, ctx.author.id)
m1 = await ctx.channel.send(f"Welcome back {ctx.author.mention}. Your AFK has been removed.")
await asyncio.sleep(5)
await m1.delete()
"""This event is fired whenever a message is sent (in a readable channel)."""
runtimeconf = api.auth.get_runtime_options()
if runtimeconf["log_messages"]:
_user = str(ctx.author).split('#')[0]
_discrim = str(ctx.author).split('#')[-1]
try:
if str(ctx.guild.id) not in runtimeconf["guild_log_blacklist"]:
if _discrim == "0000": logger.info(f"[{ctx.guild.name} -> #{ctx.channel.name}] New message received from {_user}[webhook] ({ctx.author.display_name})", timestamp=True)
elif _discrim == "0": logger.info(f"[{ctx.guild.name} -> #{ctx.channel.name}] New message received from @{_user} ({ctx.author.display_name})", timestamp=True)
else: logger.info(f"[{ctx.guild.name} -> #{ctx.channel.name}] New message received from {ctx.author} ({ctx.author.display_name})", timestamp=True)
except AttributeError:
if _discrim == "0": logger.info(f"[DM] New message received from @{_user} ({ctx.author.display_name})", timestamp=True)
elif _discrim == "0000": logger.info(f"[DM] New message received from {_user}[webhook] ({ctx.author.display_name})", timestamp=True)
else: logger.info(f"[DM] New message received from {ctx.author} ({ctx.author.display_name})", timestamp=True)
if not ctx.author.bot:
currency.new_wallet(ctx.author.id)
currency.new_bank(ctx.author.id)
create_isocoin_key(ctx.author.id)
userdata.generate(ctx.author.id)
settings.generate(ctx.author.id)
items.generate(ctx.author.id)
levelling.generate(ctx.author.id)
try: automod.generate(ctx.guild.id)
except AttributeError: pass
try:
uList = list()
presence = _presence.get_raw()
if str(ctx.guild.id) in presence:
for userid in presence[str(ctx.guild.id)].keys(): uList.append(userid)
else: pass
for user in uList:
if user in ctx.content and not ctx.author.bot:
fetch_user = client.get_user(id(user))
await ctx.channel.send(f"{fetch_user.display_name} went AFK <t:{floor(presence[str(ctx.guild.id)][str(user)]['time'])}:R>: {presence[str(ctx.guild.id)][str(user)]['response']}")
if str(ctx.guild.id) in presence and str(ctx.author.id) in presence[str(ctx.guild.id)]:
_presence.remove_afk(ctx.guild.id, ctx.author.id)
m1 = await ctx.channel.send(f"Welcome back {ctx.author.mention}. Your AFK has been removed.")
await asyncio.sleep(5)
await m1.delete()
except AttributeError: pass
levelling.add_xp(ctx.author.id, randint(1, 5))
xpreq = 0
for level in range(levelling.get_level(ctx.author.id)):
Expand Down

0 comments on commit 5913ecb

Please sign in to comment.