|
|
@@ -3,7 +3,9 @@ import discord
|
|
|
import time
|
|
|
from typing import Optional
|
|
|
from query.channel import get_interact
|
|
|
+from query.user import ignore_user, unignore_user, is_ignored
|
|
|
from common.logging import report
|
|
|
+from local_settings import COMMAND_PREFIX
|
|
|
|
|
|
def setup(bot: commands.Bot):
|
|
|
bot.add_cog(General(bot))
|
|
|
@@ -21,6 +23,10 @@ class General(commands.Cog):
|
|
|
help="Test latency by polling the gateway and API."
|
|
|
)
|
|
|
async def ping(self, ctx: commands.Context):
|
|
|
+ # Ignore user if on the ignore list.
|
|
|
+ if await is_ignored(self.bot.pg, ctx.author.id):
|
|
|
+ return
|
|
|
+
|
|
|
start_time = time.time()
|
|
|
message = await ctx.send(f"Pong!\nGateway heartbeat in {round(self.bot.latency * 1000)}ms.")
|
|
|
end_time = time.time()
|
|
|
@@ -33,6 +39,10 @@ class General(commands.Cog):
|
|
|
help="Display some crap."
|
|
|
)
|
|
|
async def info(self, ctx: commands.Context):
|
|
|
+ # Ignore user if on the ignore list.
|
|
|
+ if await is_ignored(self.bot.pg, ctx.author.id):
|
|
|
+ return
|
|
|
+
|
|
|
"""Displays some rubbish info."""
|
|
|
embed = discord.Embed(title=f"Guild: {ctx.guild}.")
|
|
|
await ctx.send(embed=embed)
|
|
|
@@ -45,6 +55,10 @@ class General(commands.Cog):
|
|
|
aliases= ("say", "pm", "dm", "echo", "print")
|
|
|
)
|
|
|
async def msg(self, ctx: commands.Context, channel: Optional[discord.TextChannel], user: Optional[discord.User], *, message: str = None):
|
|
|
+ # Ignore user if on the ignore list.
|
|
|
+ if await is_ignored(self.bot.pg, ctx.author.id):
|
|
|
+ return
|
|
|
+
|
|
|
if not message:
|
|
|
if channel:
|
|
|
await ctx.send(f"What would you like me to say in {channel}?")
|
|
|
@@ -55,7 +69,7 @@ class General(commands.Cog):
|
|
|
elif channel:
|
|
|
if await get_interact(self.bot.pg, channel.id): # or await ctx.author.get_guild_permissions(channel.guild):
|
|
|
await channel.send(message)
|
|
|
- await report(f"{ctx.author} has sent {message} to {channel.name}")
|
|
|
+ await report(self.bot, ctx.guild, f"{ctx.author} has sent {message} to {channel.name}")
|
|
|
else:
|
|
|
await ctx.send(f"Interactive mode for {channel} is deactivated.")
|
|
|
elif user:
|
|
|
@@ -63,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, f"`{ctx.author}` has sent `{message}` locally.")
|
|
|
+ await report(self.bot, ctx.guild, f"`{ctx.author}` has sent `{message}` locally.")
|
|
|
|
|
|
|
|
|
@commands.command(
|
|
|
@@ -72,6 +86,53 @@ class General(commands.Cog):
|
|
|
help="Update the bot's status."
|
|
|
)
|
|
|
async def status(self, ctx: commands.Context, *, text: str):
|
|
|
+ # Ignore user if on the ignore list.
|
|
|
+ if await is_ignored(self.bot.pg, ctx.author.id):
|
|
|
+ return
|
|
|
+
|
|
|
await self.bot.change_presence(activity=discord.Game(name=text))
|
|
|
+ await report(self.bot, f"`{ctx.author}` has set my status to `{text}`.")
|
|
|
+
|
|
|
+
|
|
|
+ @commands.command(
|
|
|
+ description="Get ignored.",
|
|
|
+ brief="Ignore sender",
|
|
|
+ help="Will have the bot ignore the user from now on."
|
|
|
+ )
|
|
|
+ async def ignoreme(self, ctx: commands.Context):
|
|
|
+ # Ignore user if on the ignore list.
|
|
|
+ if await is_ignored(self.bot.pg, ctx.author.id):
|
|
|
+ return
|
|
|
+
|
|
|
+ await ignore_user(self.bot.pg, ctx.author.id)
|
|
|
+ await ctx.send(f"To revert this use the `{COMMAND_PREFIX}unignoreme` command.")
|
|
|
+ await report(self.bot, f"`{ctx.author}` has requested to be ignored.")
|
|
|
|
|
|
|
|
|
+ @commands.command(
|
|
|
+ description="No longer get ingored.",
|
|
|
+ brief="Un-ignore sender",
|
|
|
+ help="No longer will the bot ignore the user."
|
|
|
+ )
|
|
|
+ async def unignoreme(self, ctx: commands.Context):
|
|
|
+ await unignore_user(self.bot.pg, ctx.author.id)
|
|
|
+ await ctx.send(f"I shall now interact with you again where my channel settings allow it.")
|
|
|
+ await report(self.bot, f"`{ctx.author}` has requested to be un-ignored.")
|
|
|
+
|
|
|
+ @commands.command(
|
|
|
+ description="Ignore status for user.",
|
|
|
+ brief="Check if user is ingored",
|
|
|
+ help="Verify if the user is being ignored."
|
|
|
+ )
|
|
|
+ async def isignored(self, ctx: commands.Context, user: Optional[discord.User]):
|
|
|
+ # Ignore user if on the ignore list.
|
|
|
+ if await is_ignored(self.bot.pg, ctx.author.id):
|
|
|
+ return
|
|
|
+
|
|
|
+ if not user:
|
|
|
+ user = ctx.author
|
|
|
+
|
|
|
+ if await is_ignored(self.bot.pg, user.id):
|
|
|
+ await ctx.send(f"I am ingoring `{user}`.")
|
|
|
+ else:
|
|
|
+ await ctx.send(f"I am not ignoring `{user}`.")
|