فهرست منبع

reporting & warning, but only when wanted

root 3 سال پیش
والد
کامیت
5fcd13d784
5فایلهای تغییر یافته به همراه11 افزوده شده و 8 حذف شده
  1. 2 2
      bot/commands/admin.py
  2. 2 0
      bot/commands/games.py
  3. 3 3
      bot/commands/general.py
  4. 2 2
      bot/common/logging.py
  5. 2 1
      bot/events/general.py

+ 2 - 2
bot/commands/admin.py

@@ -32,11 +32,11 @@ class Admin(commands.Cog):
 
 		if record:	# Check for active token
 			await ctx.send(f"Token {record['id']} is in use by {record['user']} until {plus10min(record['created'])}.")
-			await report(self.bot, ctx.guild, f"`{ctx.author}` has requested a token for `{ctx.guild.name}`, but got rejected until {plus10min(record['created'])} for use by `{record['user']}`.")
+			await report(self.bot, f"`{ctx.author}` has requested a token for `{ctx.guild.name}`, but got rejected until {plus10min(record['created'])} for use by `{record['user']}`.", ctx.guild)
 		else:	# No active token
 			token = secrets.token_urlsafe(40)[:40]
 			await upsert_token(self.bot.pg, ctx.guild.id, ctx.author.id, token)
 
 			await ctx.author.send(f"{WEB_SCHEME}://{WEB_HOST}/config/channel-settings/{ctx.channel.id}/{token}")	# DM token
 			await ctx.send("Your access token has been sent to you in a private DM.")
-			await report(self.bot, ctx.guild, f"`{ctx.author}` has requested a token for `{ctx.guild.name}`.")
+			await report(self.bot, f"`{ctx.author}` has requested a token for `{ctx.guild.name}`.", ctx.guild)

+ 2 - 0
bot/commands/games.py

@@ -26,6 +26,7 @@ class Games(commands.Cog):
 			return
 
 		if not await get_games(self.bot.pg, ctx.channel.id):
+			ctx.author.send(f"Games are disabled in {ctx.channel}, ask an admin to enable them.")
 			return
 		if not amount:
 			amount = 2
@@ -59,6 +60,7 @@ class Games(commands.Cog):
 			return
 
 		if not await get_games(self.bot.pg, ctx.channel.id):
+			ctx.author.send(f"Games are disabled in {ctx.channel}, ask an admin to enable them.")
 			return
 
 		if not question:

+ 3 - 3
bot/commands/general.py

@@ -67,9 +67,9 @@ class General(commands.Cog):
 			else:
 				await ctx.send("What would you like me to say?")
 		elif channel:
-			if await get_interact(self.bot.pg, channel.id): # or await ctx.author.get_guild_permissions(channel.guild):
+			if await get_interact(self.bot.pg, channel.id):
 				await channel.send(message)
-				await report(self.bot, ctx.guild, f"{ctx.author}  has sent {message} to {channel.name}")
+				await report(self.bot, f"{ctx.author}  has sent {message} to {channel.name}", ctx.guild)
 			else:
 				await ctx.send(f"Interactive mode for {channel} is deactivated.")
 		elif user:
@@ -77,7 +77,7 @@ class General(commands.Cog):
 			await report(f"{ctx.author}  has sent {message} to {user.name}")
 		else:
 			await ctx.send(message)
-			await report(self.bot, ctx.guild, f"`{ctx.author}` has sent `{message}` locally.")
+			await report(self.bot, f"`{ctx.author}` has sent `{message}` locally.", ctx.guild)
 
 
 	@commands.command(

+ 2 - 2
bot/common/logging.py

@@ -3,10 +3,10 @@ from typing import Optional
 from local_settings import OUTPUT_CHANNEL
 from query.guild import get_output_channel
 
-async def report(bot, message, *, guild: Optional[discord.Guild]=None):
+async def report(bot, message, guild: Optional[discord.Guild]=None):
     channel = bot.get_channel(OUTPUT_CHANNEL)
     if guild:
-        message = f"`{guild}` message"
+        message = f"`{guild}` | {message}"
         try: channel = bot.get_channel(get_output_channel(guild.id))
         except:
             pass

+ 2 - 1
bot/events/general.py

@@ -20,7 +20,7 @@ class General(commands.Cog):
 	@commands.Cog.listener()
 	async def on_ready(self):
 		logging.info("Logged in as %s - %i", self.bot.user.name, self.bot.user.id)
-		await report(self.bot, f"Logged in as {self.bot.user.name} - {self.bot.user.id}.")
+		#await report(self.bot, f"Logged in as {self.bot.user.name} - {self.bot.user.id}.")
 
 	@commands.Cog.listener()
 	async def on_guild_join(self, guild: discord.Guild):
@@ -61,6 +61,7 @@ class General(commands.Cog):
 
 		# Respond when mentioned
 		if self.bot.user.mentioned_in(message):
+			print(f"Message channel ID: {message.channel.id}")
 			if await get_interact(self.bot.pg, message.channel.id):
 				messages = [
 					f"Hello {message.author.mention}. <3",