Parcourir la source

News agreggation

root il y a 2 ans
Parent
commit
fbbbc0d6b3
7 fichiers modifiés avec 370 ajouts et 311 suppressions
  1. 54 31
      bot/commands/admin.py
  2. 188 188
      bot/commands/games.py
  3. 77 77
      bot/commands/general.py
  4. 32 0
      bot/events/angels.py
  5. 12 12
      bot/events/general.py
  6. 4 3
      bot/main.py
  7. 3 0
      bot/query/guild.py

+ 54 - 31
bot/commands/admin.py

@@ -1,16 +1,48 @@
-#import discord
-import secrets
+import discord
+#import secrets
 from discord.ext import commands
-from local_settings import WEB_SCHEME, WEB_HOST
-from query.guild_access_token import get_active_token, upsert_token
-from common.datetime import plus10min
-from common.logging import report
-from common.settings import check_ignore
+from discord.ui import ChannelSelect
 
+#from common.logging import report
+from common.settings import check_ignore
+from query.guild import set_output_channel
 
 async def setup(bot: commands.Bot):
 	await bot.add_cog(Admin(bot))
 
+class View(discord.ui.View):
+	def __init__(self, pg):
+		super().__init__()
+		self.pg = pg
+
+	@discord.ui.select(cls=ChannelSelect, channel_types=[discord.ChannelType.text])
+	async def select_channels(self, interaction: discord.Interaction, select: ChannelSelect):
+		await set_output_channel(self.pg, interaction.guild_id, select.values[0].id)
+		return await interaction.response.send_message(f'You selected {select.values[0].mention}')
+class Select(discord.ui.Select):
+	def __init__(self, pg, channels):
+		self.pg = pg
+		print(channels)
+		options = []
+		for channel in channels:
+			options.append(discord.SelectOption(label=str(channel.name),emoji="👌",description=str(channel.category)),)
+		print(options)
+		#options=[
+		#	discord.SelectOption(label="Option 1",emoji="👌",description="This is option 1!"),
+		#	discord.SelectOption(label="Option 2",emoji="✨",description="This is option 2!"),
+		#	discord.SelectOption(label="Option 3",emoji="🎭",description="This is option 3!")
+		#	]
+		super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
+	async def callback(self, interaction: discord.Interaction):
+		await set_output_channel(self.pg, interaction.guild_id, 971796738484625468)
+		await interaction.response.send_message(content=f"Your choice is {self.values[0]}!", ephemeral=True)
+
+
+class SelectView(discord.ui.View):
+	def __init__(self, pg, channels, *, timeout = 180):
+		super().__init__(timeout=timeout)
+		self.add_item(Select(pg, channels))
+
 
 class Admin(commands.Cog):
 	"""Administrative functionality."""
@@ -18,27 +50,18 @@ class Admin(commands.Cog):
 	def __init__(self, bot: commands.Bot):
 		self.bot = bot
 
-	@commands.command(
-		description="Modify channel settings via a browser",
-		brief="Set channel specific settings via the webgui",
-		help="Sends a single-use time based token to the webportal"
-	)
-	@commands.has_guild_permissions(administrator=True)
-	async def webset(self, ctx: commands.Context):
-
-		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, ctx.author):
-			return
-
-		record = await get_active_token(self.bot.pg, ctx.guild.id)
-
-		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, 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, f"`{ctx.author}` has requested a token for `{ctx.guild.name}`.", ctx.guild)
+	# @commands.command(
+	# 	description="Modify channel settings via a browser",
+	# 	brief="Set channel specific settings via the webgui",
+	# 	help="Sends a single-use time based token to the webportal"
+	# )
+	# #@commands.has_guild_permissions(administrator=True)
+	# async def guildsettings(self, ctx: commands.Context):
+	#
+	# 	# Halt on ignore list.
+	# 	if await check_ignore(self.bot.pg, ctx.author):
+	# 		return
+	#
+	# 	#await ctx.send("Menus!", view=SelectView(self.bot.pg, ctx.guild.channels))
+	# 	await ctx.send("Menus!", view=View(self.bot.pg), ephemeral=True)
+

+ 188 - 188
bot/commands/games.py

@@ -3,7 +3,7 @@ import discord
 import random
 from typing import Optional
 from query.user import is_ignored, get_level, get_xp, level_up, get_ability_points_spent, increment_all_coin, get_coin, get_karma, get_theft_skill, get_random_player
-from local_settings import COMMAND_PREFIX
+#from local_settings import COMMAND_PREFIX
 from common.settings import check_ignore
 
 
@@ -17,190 +17,190 @@ class Games(commands.Cog):
 	def __init__(self, bot: commands.Bot):
 		self.bot = bot
 
-	@commands.command(
-		description="Check the level for a player.",
-		brief="Get player level",
-		help="View game level of player."
-	)
-	async def level(self, ctx: commands.Context, user: Optional[discord.User]):
-		# Halt on ignore list or games channel settings.
-		if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
-			return
-
-		if not user:
-			user = ctx.author
-		level = await get_level(self.bot.pg, user.id)
-
-		if level == 0:
-			if ctx.author == user:
-				await ctx.send(f"You are not playing, join the game with `{COMMAND_PREFIX}levelup`")
-			else:
-				await ctx.send(f"`{user}` is not playing.")
-		else:
-			xp_spent, total_xp = await get_xp(self.bot.pg, user.id)
-			ability_points_spent = await get_ability_points_spent(self.bot.pg, user.id)
-			coin = await get_coin(self.bot.pg, user.id)
-			karma = await get_karma(self.bot.pg, user.id)
-			if ctx.author == user:
-				await ctx.send(f"You rank at level **{level}**. (exp **{xp_spent}**/{total_xp} | abp **{ability_points_spent}**/{level * 3} | coin **{coin}** | karma **{karma}**)")
-			else:
-				await ctx.send(f"`{user}` ranks at level **{level}**. (**{xp_spent}**/{total_xp} | abp **{ability_points_spent}**/{level * 3}) | coin **{coin}** | karma **{karma}**")
-
-	@commands.command(
-		description="Check the experience points for a player.",
-		brief="Get player xp",
-		help="View amount of XP a game player has."
-	)
-	async def xp(self, ctx: commands.Context, user: Optional[discord.User]):
-		# Halt on ignore list or games channel settings.
-		if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
-			return
-
-		if not user:
-			xp_spent, total_xp = await get_xp(self.bot.pg, ctx.author.id)
-			level = await get_level(self.bot.pg, ctx.author.id)
-			threshold = (level + 1) * 50 + xp_spent
-			if threshold < total_xp - xp_spent:
-				await ctx.send(f"You have spent {xp_spent} experience points of your {total_xp} total and can gain 3 ability points for {threshold} xp.")
-			else:
-				await ctx.send(f"You have spent {xp_spent} experience points of your {total_xp} total and require {threshold - (total_xp - xp_spent)} xp to `{COMMAND_PREFIX}levelup`.")
-		else:
-			xp_spent, total_xp = await get_xp(self.bot.pg, user.id)
-			level = await get_level(self.bot.pg, user.id)
-			threshold = (level + 1) * 50 + xp_spent
-			if threshold < total_xp - xp_spent:
-				await ctx.send(f"`{user}` has spent {xp_spent} of {total_xp} experience points and can level up for {threshold} xp.")
-			else:
-				await ctx.send(f"`{user}` has spent {xp_spent} of {total_xp} experience points and requires {threshold - (total_xp - xp_spent)} xp to level up.")
-
-	@commands.command(
-		description="Attempt to gain a level.",
-		brief="Level up",
-		help="Try to rank up a level in the game by spending XP."
-	)
-	async def levelup(self, ctx: commands.Context):
-		# Halt on ignore list or games channel settings.
-		if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
-			return
-
-		xp_spent, total_xp = await get_xp(self.bot.pg, ctx.author.id)
-		xp_available = total_xp - xp_spent
-		level = await get_level(self.bot.pg, ctx.author.id)
-		threshold = (level + 1) * 50 + xp_spent
-		if xp_available < threshold:
-			await ctx.send(f"Not yet, you require {threshold - xp_available} more XP to level up.")
-		else:
-			await level_up(self.bot.pg, ctx.author.id, threshold)
-			await ctx.send(f"You have gained three ability points climbed the ranks for {threshold} XP, leaving you {xp_available - threshold} remaining.")
-			await increment_all_coin(self.bot.pg)
-
-	@commands.command(
-		description="Rob another player",
-		brief="Rob a player",
-		help="Pursuit a robbery."
-	)
-	async def rob(self, ctx: commands.Context):
-		# Halt on ignore list or games channel settings.
-		if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
-			return
-
-		if get_theft_skill(self.bot.pg, ctx.author.id < 1):
-			await ctx.send("You do not have the `Theft` skill.")
-			return
-
-		victim_id = get_random_player(self.bot.pg)
-		await ctx.send(f"You have decided to rob{self.bot.get_user(victim_id)}, unfortunately crime has not been invited yet.")
-
-	@commands.command(
-		description="Simulate dice rolls.",
-		brief="Roll dice",
-		help="Roll two dice."
-	)
-	async def dice(self, ctx: commands.Context, amount: Optional[int], sides: Optional[int]):
-		# Halt on ignore list or games channel settings.
-		if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
-			return
-
-		if not amount:
-			amount = 2
-		if not sides:
-			sides = 6
-
-		if amount < 1:
-			await ctx.send("You want me to roll less than one die? How!?")
-		elif amount > 25:
-			await ctx.send("I can not hold so many dice at one time.")
-		elif sides < 2:
-			await ctx.send("A die has physical minimum of 2 sides. Don't ask for impossible objects.")
-		elif sides > 256:
-			await ctx.send("My tiny hands can not handle such large dice. Even if both are virtual.")
-		else:
-			embed = discord.Embed(title = "Dice roll", description=f"Rolling {amount} dice, with {sides} sides.")
-			while amount > 0:
-				embed.insert_field_at(0, name=f"Die {amount}", value=random.randint(1, sides), inline=True)
-				amount -= 1
-			await ctx.send(embed=embed)
-
-	@commands.command(
-		description="Ask the magic 8-ball.",
-		brief="Pose question",
-		help="Simulate the iconic 8-ball gimmic.",
-		name="8ball"
-	)
-	async def eightball(self, ctx: commands.Context, *, question: str = None):
-		# Halt on ignore list or games channel settings.
-		if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
-			return
-
-		if not question:
-			messages = [
-				"Don't forget to ask a question...",
-				"Hey, that's not a question!",
-				"What would you like to know?",
-				"You want me to predict nothing?",
-				"Are you intentionally not asking a question?",
-				"Ask a question you tease!",
-				"You will die alone.",
-			]
-		elif question.strip().count(" ") == 0:
-			messages = [
-				"What?",
-				"That is not a question",
-				"Can you use more than one word?",
-				"What is the question?",
-				"Sorry?"
-			]
-		elif question.strip()[-1] != "?":
-			messages = [
-				"Did you forget to end with a question mark?",
-				"Is that a statement or question?",
-				"Don't questions usually end with a question mark?",
-				"Don't forget to use punctuation."
-			]
-		else:
-			messages = [
-				"Yes.",
-				"No.",
-				"Affirmative.",
-				"No way!",
-				"Negative.",
-				"Positive.",
-				"Correct.",
-				"Incorrect.",
-				"Likely",
-				"Unlikely",
-				"Maybe.",
-				"Definately!",
-				"Perhaps?",
-				"Most indubitably.",
-				"Does the pope shit in the woods?",
-				"When hell freezes over.",
-				"Only between 9 and 5.",
-				"Only just before you die.",
-				"ERROR: Probability failure.",
-				"Ask again later.",
-				"I don't know.",
-				"Unpredictable.",
-				"Unknown",
-			]
-		await ctx.send(random.choice(messages))
+	# @commands.command(
+	# 	description="Check the level for a player.",
+	# 	brief="Get player level",
+	# 	help="View game level of player."
+	# )
+	# async def level(self, ctx: commands.Context, user: Optional[discord.User]):
+	# 	# Halt on ignore list or games channel settings.
+	# 	if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
+	# 		return
+	#
+	# 	if not user:
+	# 		user = ctx.author
+	# 	level = await get_level(self.bot.pg, user.id)
+	#
+	# 	if level == 0:
+	# 		if ctx.author == user:
+	# 			await ctx.send(f"You are not playing, join the game with `/levelup`")
+	# 		else:
+	# 			await ctx.send(f"`{user}` is not playing.")
+	# 	else:
+	# 		xp_spent, total_xp = await get_xp(self.bot.pg, user.id)
+	# 		ability_points_spent = await get_ability_points_spent(self.bot.pg, user.id)
+	# 		coin = await get_coin(self.bot.pg, user.id)
+	# 		karma = await get_karma(self.bot.pg, user.id)
+	# 		if ctx.author == user:
+	# 			await ctx.send(f"You rank at level **{level}**. (exp **{xp_spent}**/{total_xp} | abp **{ability_points_spent}**/{level * 3} | coin **{coin}** | karma **{karma}**)")
+	# 		else:
+	# 			await ctx.send(f"`{user}` ranks at level **{level}**. (**{xp_spent}**/{total_xp} | abp **{ability_points_spent}**/{level * 3}) | coin **{coin}** | karma **{karma}**")
+	#
+	# @commands.command(
+	# 	description="Check the experience points for a player.",
+	# 	brief="Get player xp",
+	# 	help="View amount of XP a game player has."
+	# )
+	# async def xp(self, ctx: commands.Context, user: Optional[discord.User]):
+	# 	# Halt on ignore list or games channel settings.
+	# 	if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
+	# 		return
+	#
+	# 	if not user:
+	# 		xp_spent, total_xp = await get_xp(self.bot.pg, ctx.author.id)
+	# 		level = await get_level(self.bot.pg, ctx.author.id)
+	# 		threshold = (level + 1) * 50 + xp_spent
+	# 		if threshold < total_xp - xp_spent:
+	# 			await ctx.send(f"You have spent {xp_spent} experience points of your {total_xp} total and can gain 3 ability points for {threshold} xp.")
+	# 		else:
+	# 			await ctx.send(f"You have spent {xp_spent} experience points of your {total_xp} total and require {threshold - (total_xp - xp_spent)} xp to `/levelup`.")
+	# 	else:
+	# 		xp_spent, total_xp = await get_xp(self.bot.pg, user.id)
+	# 		level = await get_level(self.bot.pg, user.id)
+	# 		threshold = (level + 1) * 50 + xp_spent
+	# 		if threshold < total_xp - xp_spent:
+	# 			await ctx.send(f"`{user}` has spent {xp_spent} of {total_xp} experience points and can level up for {threshold} xp.")
+	# 		else:
+	# 			await ctx.send(f"`{user}` has spent {xp_spent} of {total_xp} experience points and requires {threshold - (total_xp - xp_spent)} xp to level up.")
+	#
+	# @commands.command(
+	# 	description="Attempt to gain a level.",
+	# 	brief="Level up",
+	# 	help="Try to rank up a level in the game by spending XP."
+	# )
+	# async def levelup(self, ctx: commands.Context):
+	# 	# Halt on ignore list or games channel settings.
+	# 	if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
+	# 		return
+	#
+	# 	xp_spent, total_xp = await get_xp(self.bot.pg, ctx.author.id)
+	# 	xp_available = total_xp - xp_spent
+	# 	level = await get_level(self.bot.pg, ctx.author.id)
+	# 	threshold = (level + 1) * 50 + xp_spent
+	# 	if xp_available < threshold:
+	# 		await ctx.send(f"Not yet, you require {threshold - xp_available} more XP to level up.")
+	# 	else:
+	# 		await level_up(self.bot.pg, ctx.author.id, threshold)
+	# 		await ctx.send(f"You have gained three ability points climbed the ranks for {threshold} XP, leaving you {xp_available - threshold} remaining.")
+	# 		await increment_all_coin(self.bot.pg)
+	#
+	# @commands.command(
+	# 	description="Rob another player",
+	# 	brief="Rob a player",
+	# 	help="Pursuit a robbery."
+	# )
+	# async def rob(self, ctx: commands.Context):
+	# 	# Halt on ignore list or games channel settings.
+	# 	if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
+	# 		return
+	#
+	# 	if get_theft_skill(self.bot.pg, ctx.author.id < 1):
+	# 		await ctx.send("You do not have the `Theft` skill.")
+	# 		return
+	#
+	# 	victim_id = get_random_player(self.bot.pg)
+	# 	await ctx.send(f"You have decided to rob{self.bot.get_user(victim_id)}, unfortunately crime has not been invited yet.")
+	#
+	# @commands.command(
+	# 	description="Simulate dice rolls.",
+	# 	brief="Roll dice",
+	# 	help="Roll two dice."
+	# )
+	# async def dice(self, ctx: commands.Context, amount: Optional[int], sides: Optional[int]):
+	# 	# Halt on ignore list or games channel settings.
+	# 	if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
+	# 		return
+	#
+	# 	if not amount:
+	# 		amount = 2
+	# 	if not sides:
+	# 		sides = 6
+	#
+	# 	if amount < 1:
+	# 		await ctx.send("You want me to roll less than one die? How!?")
+	# 	elif amount > 25:
+	# 		await ctx.send("I can not hold so many dice at one time.")
+	# 	elif sides < 2:
+	# 		await ctx.send("A die has physical minimum of 2 sides. Don't ask for impossible objects.")
+	# 	elif sides > 256:
+	# 		await ctx.send("My tiny hands can not handle such large dice. Even if both are virtual.")
+	# 	else:
+	# 		embed = discord.Embed(title = "Dice roll", description=f"Rolling {amount} dice, with {sides} sides.")
+	# 		while amount > 0:
+	# 			embed.insert_field_at(0, name=f"Die {amount}", value=random.randint(1, sides), inline=True)
+	# 			amount -= 1
+	# 		await ctx.send(embed=embed)
+	#
+	# @commands.command(
+	# 	description="Ask the magic 8-ball.",
+	# 	brief="Pose question",
+	# 	help="Simulate the iconic 8-ball gimmic.",
+	# 	name="8ball"
+	# )
+	# async def eightball(self, ctx: commands.Context, *, question: str = None):
+	# 	# Halt on ignore list or games channel settings.
+	# 	if await check_ignore(self.bot.pg, ctx.author, ctx.channel):
+	# 		return
+	#
+	# 	if not question:
+	# 		messages = [
+	# 			"Don't forget to ask a question...",
+	# 			"Hey, that's not a question!",
+	# 			"What would you like to know?",
+	# 			"You want me to predict nothing?",
+	# 			"Are you intentionally not asking a question?",
+	# 			"Ask a question you tease!",
+	# 			"You will die alone.",
+	# 		]
+	# 	elif question.strip().count(" ") == 0:
+	# 		messages = [
+	# 			"What?",
+	# 			"That is not a question",
+	# 			"Can you use more than one word?",
+	# 			"What is the question?",
+	# 			"Sorry?"
+	# 		]
+	# 	elif question.strip()[-1] != "?":
+	# 		messages = [
+	# 			"Did you forget to end with a question mark?",
+	# 			"Is that a statement or question?",
+	# 			"Don't questions usually end with a question mark?",
+	# 			"Don't forget to use punctuation."
+	# 		]
+	# 	else:
+	# 		messages = [
+	# 			"Yes.",
+	# 			"No.",
+	# 			"Affirmative.",
+	# 			"No way!",
+	# 			"Negative.",
+	# 			"Positive.",
+	# 			"Correct.",
+	# 			"Incorrect.",
+	# 			"Likely",
+	# 			"Unlikely",
+	# 			"Maybe.",
+	# 			"Definately!",
+	# 			"Perhaps?",
+	# 			"Most indubitably.",
+	# 			"Does the pope shit in the woods?",
+	# 			"When hell freezes over.",
+	# 			"Only between 9 and 5.",
+	# 			"Only just before you die.",
+	# 			"ERROR: Probability failure.",
+	# 			"Ask again later.",
+	# 			"I don't know.",
+	# 			"Unpredictable.",
+	# 			"Unknown",
+	# 		]
+	# 	await ctx.send(random.choice(messages))

+ 77 - 77
bot/commands/general.py

@@ -5,7 +5,7 @@ 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, OUTPUT_CHANNEL
+from local_settings import OUTPUT_CHANNEL
 from common.settings import check_ignore
 
 
@@ -19,81 +19,81 @@ class GeneralCommands(commands.Cog):
 	def __init__(self, bot: commands.Bot):
 		self.bot = bot
 
-	@commands.command(
-		description="Get the bot's current websocket and API latency.",
-		brief="Test latency",
-		help="Test latency by polling the gateway and API."
-	)
-	async def ping(self, ctx: commands.Context):
-		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, ctx.author):
-			return
-
-		start_time = time.time()
-		message = await ctx.send(f"Pong!\nGateway heartbeat in {round(self.bot.latency * 1000)}ms.")
-		end_time = time.time()
-
-		await ctx.send(f"API roundtrip latency {round((end_time - start_time) * 1000)}ms.")
-
-	@commands.command(
-		description="Rubbish information.",
-		brief="Get info",
-		help="Display some crap."
-	)
-	async def info(self, ctx: commands.Context):
-		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, ctx.author):
-			return
-
-		"""Displays some rubbish info."""
-		embed = discord.Embed(title=f"Guild: {ctx.guild}.")
-		await ctx.send(embed=embed)
-		#await ctx.send(f"Guild: {ctx.guild}.")
-
-	@commands.command(
-		description="Send a message",
-		brief="Chat",
-		help="Make a chat message",
-		aliases= ("say", "pm", "dm", "echo", "print")
-	)
-	async def msg(self, ctx: commands.Context, channel: Optional[discord.TextChannel], user: Optional[discord.User], *, message: str = None):
-		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, ctx.author):
-			return
-
-		#print(ctx.author.permissions_in(self.bot.get_channel(OUTPUT_CHANNEL)).send_messages)
-		if not message:
-			if channel:
-				await ctx.send(f"What would you like me to say in `{channel}`?")
-			elif user:
-				await ctx.send(f"What would you like me to say to `{user}`?")
-			else:
-				await ctx.send("What would you like me to say?")
-		elif channel:
-			if await get_interact(self.bot.pg, channel.id) or ctx.author.permissions_in(self.bot.get_channel(OUTPUT_CHANNEL)).send_messages:
-				await channel.send(message)
-				await report(self.bot, f"`{ctx.author}` @ {channel.mention}: {message}", ctx.guild)
-			else:
-				await ctx.send(f"Interactive mode for {channel} is deactivated.")
-		elif user and ctx.author.permissions_in(self.bot.get_channel(OUTPUT_CHANNEL)).send_messages:
-			await user.send(message)
-			await report(self.bot, 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.", ctx.guild)
-
-	@commands.command(
-		description="Change status.",
-		brief="Set status",
-		help="Update the bot's status."
-	)
-	async def status(self, ctx: commands.Context, *, text: str):
-		# Halt on ignore list.
-		if await check_ignore(self.bot.pg, ctx.author):
-			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 the bot's current websocket and API latency.",
+	# 	brief="Test latency",
+	# 	help="Test latency by polling the gateway and API."
+	# )
+	# async def ping(self, ctx: commands.Context):
+	# 	# Halt on ignore list.
+	# 	if await check_ignore(self.bot.pg, ctx.author):
+	# 		return
+	#
+	# 	start_time = time.time()
+	# 	message = await ctx.send(f"Pong!\nGateway heartbeat in {round(self.bot.latency * 1000)}ms.")
+	# 	end_time = time.time()
+	#
+	# 	await ctx.send(f"API roundtrip latency {round((end_time - start_time) * 1000)}ms.")
+
+	# @commands.command(
+	# 	description="Rubbish information.",
+	# 	brief="Get info",
+	# 	help="Display some crap."
+	# )
+	# async def info(self, ctx: commands.Context):
+	# 	# Halt on ignore list.
+	# 	if await check_ignore(self.bot.pg, ctx.author):
+	# 		return
+	#
+	# 	"""Displays some rubbish info."""
+	# 	embed = discord.Embed(title=f"Guild: {ctx.guild}.")
+	# 	await ctx.send(embed=embed)
+	# 	#await ctx.send(f"Guild: {ctx.guild}.")
+
+	# @commands.command(
+	# 	description="Send a message",
+	# 	brief="Chat",
+	# 	help="Make a chat message",
+	# 	aliases= ("say", "pm", "dm", "echo", "print")
+	# )
+	# async def msg(self, ctx: commands.Context, channel: Optional[discord.TextChannel], user: Optional[discord.User], *, message: str = None):
+	# 	# Halt on ignore list.
+	# 	if await check_ignore(self.bot.pg, ctx.author):
+	# 		return
+	#
+	# 	#print(ctx.author.permissions_in(self.bot.get_channel(OUTPUT_CHANNEL)).send_messages)
+	# 	if not message:
+	# 		if channel:
+	# 			await ctx.send(f"What would you like me to say in `{channel}`?")
+	# 		elif user:
+	# 			await ctx.send(f"What would you like me to say to `{user}`?")
+	# 		else:
+	# 			await ctx.send("What would you like me to say?")
+	# 	elif channel:
+	# 		if await get_interact(self.bot.pg, channel.id) or ctx.author.permissions_in(self.bot.get_channel(OUTPUT_CHANNEL)).send_messages:
+	# 			await channel.send(message)
+	# 			await report(self.bot, f"`{ctx.author}` @ {channel.mention}: {message}", ctx.guild)
+	# 		else:
+	# 			await ctx.send(f"Interactive mode for {channel} is deactivated.")
+	# 	elif user and ctx.author.permissions_in(self.bot.get_channel(OUTPUT_CHANNEL)).send_messages:
+	# 		await user.send(message)
+	# 		await report(self.bot, 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.", ctx.guild)
+
+	# @commands.command(
+	# 	description="Change status.",
+	# 	brief="Set status",
+	# 	help="Update the bot's status."
+	# )
+	# async def status(self, ctx: commands.Context, *, text: str):
+	# 	# Halt on ignore list.
+	# 	if await check_ignore(self.bot.pg, ctx.author):
+	# 		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.",
@@ -106,7 +106,7 @@ class GeneralCommands(commands.Cog):
 			return
 
 		await ignore_user(self.bot.pg, ctx.author.id)
-		await ctx.send(f"To revert this use the `{COMMAND_PREFIX}unignoreme` command.")
+		await ctx.send(f"To revert this use the `/unignoreme` command.")
 		await report(self.bot, f"`{ctx.author}` has requested to be ignored.")
 
 	@commands.command(

+ 32 - 0
bot/events/angels.py

@@ -0,0 +1,32 @@
+import discord
+from discord.ext import commands
+
+async def setup(bot: commands.Bot):
+	await bot.add_cog(AngelEvents(bot))
+
+class AngelEvents(commands.Cog):
+	"""A couple of simple commands."""
+
+	def __init__(self, bot: commands.Bot):
+		self.bot = bot
+
+	@commands.Cog.listener()
+	async def on_message(self, message: discord.Message):
+		feed_channels = [1184948763614253187]
+		if message.channel.id in feed_channels:
+			news_channel = self.bot.get_channel(971796738484625468)
+			if message.type == discord.MessageType.channel_follow_add:
+				source_channel = self.bot.get_channel(message.reference.channel_id)
+				if source_channel:
+					source_invite = await source_channel.create_invite(unique=False, reason="Linking back to discord of which news is being repeated.")
+					await news_channel.send(message.author.mention + " [" + message.system_content.partition()[2] + "](" + source_invite + ")")
+				else:
+					await news_channel.send(message.author.mention + " " + message.system_content.partition(" ")[2])
+			else:
+				if message.author.bot:
+					source_channel = self.bot.get_channel(message.reference.channel_id)
+					if source_channel:
+						source_invite = await source_channel.create_invite(unique=False, reason="Linking back to discord of which news is being repeated.")
+						msg = await news_channel.send("**[" + message.author.name + "](<" + source_invite.url + ">)**:\n\n" + message.clean_content)
+					else:
+						await news_channel.send("**" + message.author.name + "**:\n\n" + message.clean_content)

+ 12 - 12
bot/events/general.py

@@ -250,15 +250,15 @@ class GeneralEvents(commands.Cog):
 	async def on_thread_member_remove(self, member: discord.User):
 		left_thread(self.bot.pg, member.id)
 
-	@commands.command(name="snipe")
-	async def snipe(self, ctx: commands.Context):  # Undelete last deleted message
-		"""A command to snipe delete messages."""
-		if not self.last_deteled_msg:  # on_message_delete hasn't been triggered since the bot started
-			await ctx.send("There is no message to snipe!")
-			return
-
-		author = self.last_deleted_msg.author
-		content = self.last_deleted_msg.content
-
-		embed = discord.Embed(title=f"Message from {author}", description=content)
-		await ctx.send(embed=embed)
+	# @commands.command(name="snipe")
+	# async def snipe(self, ctx: commands.Context):  # Undelete last deleted message
+	# 	"""A command to snipe delete messages."""
+	# 	if not self.last_deteled_msg:  # on_message_delete hasn't been triggered since the bot started
+	# 		await ctx.send("There is no message to snipe!")
+	# 		return
+	#
+	# 	author = self.last_deleted_msg.author
+	# 	content = self.last_deleted_msg.content
+	#
+	# 	embed = discord.Embed(title=f"Message from {author}", description=content)
+	# 	await ctx.send(embed=embed)

+ 4 - 3
bot/main.py

@@ -75,7 +75,7 @@ async def main():
 	intents.message_content = True
 	try:
 		bot = commands.Bot(
-			command_prefix=settings.COMMAND_PREFIX,
+			command_prefix="/",
 			description="Charlie's Angels bot",
 			intents=intents,
 			case_insensitive=True,
@@ -85,10 +85,11 @@ async def main():
 
 	# Load extensions
 	default_extensions = [
-		"commands.admin",
-		"commands.games",
+		#"commands.admin",
+		#"commands.games",
 		"commands.general",
 		"events.general",
+		"events.angels",
 	]
 	for ext in default_extensions:
 		logging.info(f"Loading extension: {ext}")

+ 3 - 0
bot/query/guild.py

@@ -6,6 +6,9 @@ async def update_guild(pg, guild):
 async def get_output_channel(pg, guild_id):
 	return await pg.fetchval("SELECT output_channel FROM guild WHERE guild_id = $1", guild_id)
 
+async def set_output_channel(pg, guild_id, value):
+	return await pg.execute("UPDATE guild SET output_channel = $1 WHERE guild_id = $2 ", value, guild_id)
+
 async def get_report_deleted(pg, guild_id):
 	return await pg.fetchval("SELECT report_deleted FROM guild WHERE guild_id = $1", guild_id)