aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/__init__.py4
-rw-r--r--bot/__main__.py1
-rw-r--r--bot/cogs/antispam.py20
-rw-r--r--bot/cogs/information.py4
-rw-r--r--bot/cogs/moderation.py4
-rw-r--r--bot/cogs/site.py98
-rw-r--r--bot/constants.py1
-rw-r--r--config-default.yml49
8 files changed, 151 insertions, 30 deletions
diff --git a/bot/__init__.py b/bot/__init__.py
index df168cba4..5a446d71c 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -88,7 +88,9 @@ for key, value in logging.Logger.manager.loggerDict.items():
value.addHandler(handler)
-# Silence discord and websockets
+# Silence aio_pika.pika.{callback,channel}, discord, PIL, and and websockets
+logging.getLogger("aio_pika.pika.callback").setLevel(logging.ERROR)
+logging.getLogger("aio_pika.pika.channel").setLevel(logging.ERROR)
logging.getLogger("discord.client").setLevel(logging.ERROR)
logging.getLogger("discord.gateway").setLevel(logging.ERROR)
logging.getLogger("discord.state").setLevel(logging.ERROR)
diff --git a/bot/__main__.py b/bot/__main__.py
index a2c10476c..aa73e42bd 100644
--- a/bot/__main__.py
+++ b/bot/__main__.py
@@ -65,6 +65,7 @@ bot.load_extension("bot.cogs.information")
bot.load_extension("bot.cogs.moderation")
bot.load_extension("bot.cogs.off_topic_names")
bot.load_extension("bot.cogs.reddit")
+bot.load_extension("bot.cogs.site")
bot.load_extension("bot.cogs.snakes")
bot.load_extension("bot.cogs.snekbox")
bot.load_extension("bot.cogs.tags")
diff --git a/bot/cogs/antispam.py b/bot/cogs/antispam.py
index 04b030889..21161ff04 100644
--- a/bot/cogs/antispam.py
+++ b/bot/cogs/antispam.py
@@ -9,7 +9,11 @@ from discord import Member, Message, Object, TextChannel
from discord.ext.commands import Bot
from bot import rules
-from bot.constants import AntiSpam as AntiSpamConfig, Channels, Colours, Guild as GuildConfig, Icons
+from bot.constants import (
+ AntiSpam as AntiSpamConfig, Channels,
+ Colours, Guild as GuildConfig,
+ Icons, Roles
+)
from bot.utils.time import humanize as humanize_delta
@@ -27,6 +31,13 @@ RULE_FUNCTION_MAPPING = {
'newlines': rules.apply_newlines,
'role_mentions': rules.apply_role_mentions
}
+WHITELISTED_CHANNELS = (
+ Channels.admin, Channels.announcements, Channels.big_brother_logs,
+ Channels.devalerts, Channels.devlog, Channels.devtest,
+ Channels.helpers, Channels.message_log,
+ Channels.mod_alerts, Channels.modlog, Channels.staff_lounge
+)
+WHITELISTED_ROLES = (Roles.owner, Roles.admin, Roles.moderator, Roles.helpers)
class AntiSpam:
@@ -39,7 +50,12 @@ class AntiSpam:
self.muted_role = Object(role_id)
async def on_message(self, message: Message):
- if message.guild.id != GuildConfig.id or message.author.bot:
+ if (
+ message.guild.id != GuildConfig.id
+ or message.author.bot
+ or message.channel.id in WHITELISTED_CHANNELS
+ or message.author.top_role.id in WHITELISTED_ROLES
+ ):
return
# Fetch the rule configuration with the highest rule interval.
diff --git a/bot/cogs/information.py b/bot/cogs/information.py
index ddc18fcf8..2390334d8 100644
--- a/bot/cogs/information.py
+++ b/bot/cogs/information.py
@@ -6,7 +6,8 @@ from dateutil.relativedelta import relativedelta
from discord import CategoryChannel, Colour, Embed, Member, TextChannel, VoiceChannel
from discord.ext.commands import Bot, Context, command
-from bot.constants import Emojis, Keys, URLs
+from bot.constants import Emojis, Keys, Roles, URLs
+from bot.decorators import with_role
from bot.utils.time import humanize
log = logging.getLogger(__name__)
@@ -23,6 +24,7 @@ class Information:
self.bot = bot
self.headers = {"X-API-Key": Keys.site_api}
+ @with_role(Roles.owner, Roles.admin, Roles.moderator)
@command(name="roles")
async def roles_info(self, ctx: Context):
"""
diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py
index b04887b3f..ee28a3600 100644
--- a/bot/cogs/moderation.py
+++ b/bot/cogs/moderation.py
@@ -172,7 +172,7 @@ class Moderation:
self.mod_log.ignore(Event.member_ban, user.id)
self.mod_log.ignore(Event.member_remove, user.id)
- await ctx.guild.ban(user, reason=reason)
+ await ctx.guild.ban(user, reason=reason, delete_message_days=0)
if reason is None:
result_message = f":ok_hand: permanently banned {user.mention}."
@@ -349,7 +349,7 @@ class Moderation:
self.mod_log.ignore(Event.member_ban, user.id)
self.mod_log.ignore(Event.member_remove, user.id)
guild: Guild = ctx.guild
- await guild.ban(user, reason=reason)
+ await guild.ban(user, reason=reason, delete_message_days=0)
infraction_object = response_object["infraction"]
infraction_expiration = infraction_object["expires_at"]
diff --git a/bot/cogs/site.py b/bot/cogs/site.py
new file mode 100644
index 000000000..e5fd645fb
--- /dev/null
+++ b/bot/cogs/site.py
@@ -0,0 +1,98 @@
+import logging
+
+from discord import Colour, Embed
+from discord.ext.commands import Bot, Context, group
+
+from bot.constants import URLs
+
+log = logging.getLogger(__name__)
+
+INFO_URL = f"{URLs.site_schema}{URLs.site}/info"
+
+
+class Site:
+ """Commands for linking to different parts of the site."""
+
+ def __init__(self, bot: Bot):
+ self.bot = bot
+
+ @group(name="site", aliases=("s",), invoke_without_command=True)
+ async def site_group(self, ctx):
+ """Commands for getting info about our website."""
+
+ await ctx.invoke(self.bot.get_command("help"), "site")
+
+ @site_group.command(name="home", aliases=("about",))
+ async def site_main(self, ctx: Context):
+ """Info about the website itself."""
+
+ url = f"{URLs.site_schema}{URLs.site}/"
+
+ embed = Embed(title="Python Discord website")
+ embed.set_footer(text=url)
+ embed.colour = Colour.blurple()
+ embed.description = (
+ f"[Our official website]({url}) is an open-source community project "
+ "created with Python and Flask. It contains information about the server "
+ "itself, lets you sign up for upcoming events, has its own wiki, contains "
+ "a list of valuable learning resources, and much more."
+ )
+
+ await ctx.send(embed=embed)
+
+ @site_group.command(name="resources")
+ async def site_resources(self, ctx: Context):
+ """Info about the site's Resources page."""
+
+ url = f"{INFO_URL}/resources"
+
+ embed = Embed(title="Resources")
+ embed.set_footer(text=url)
+ embed.colour = Colour.blurple()
+ embed.description = (
+ f"The [Resources page]({url}) on our website contains a "
+ "list of hand-selected goodies that we regularly recommend "
+ "to both beginners and experts."
+ )
+
+ await ctx.send(embed=embed)
+
+ @site_group.command(name="help")
+ async def site_help(self, ctx: Context):
+ """Info about the site's Getting Help page."""
+
+ url = f"{INFO_URL}/help"
+
+ embed = Embed(title="Getting Help")
+ embed.set_footer(text=url)
+ embed.colour = Colour.blurple()
+ embed.description = (
+ "Asking the right question about something that's new to you can sometimes be tricky. "
+ f"To help with this, we've created a [guide to asking good questions]({url}) on our website. "
+ "It contains everything you need to get the very best help from our community."
+ )
+
+ await ctx.send(embed=embed)
+
+ @site_group.command(name="faq")
+ async def site_faq(self, ctx: Context):
+ """Info about the site's FAQ page."""
+
+ url = f"{INFO_URL}/faq"
+
+ embed = Embed(title="FAQ")
+ embed.set_footer(text=url)
+ embed.colour = Colour.blurple()
+ embed.description = (
+ "As the largest Python community on Discord, we get hundreds of questions every day. "
+ "Many of these questions have been asked before. We've compiled a list of the most "
+ "frequently asked questions along with their answers, which can be found on "
+ f"our [FAQ page]({url})."
+ )
+
+ await ctx.send(embed=embed)
+
+
+def setup(bot):
+ bot.add_cog(Site(bot))
+ log.info("Cog loaded: Site")
diff --git a/bot/constants.py b/bot/constants.py
index 5e1dc1e39..1e789ff3a 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -385,6 +385,7 @@ class URLs(metaclass=YAMLGetter):
gitlab_bot_repo: str
omdb: str
site: str
+ site_api: str
site_facts_api: str
site_clean_api: str
site_clean_logs: str
diff --git a/config-default.yml b/config-default.yml
index fd0e33633..772169a29 100644
--- a/config-default.yml
+++ b/config-default.yml
@@ -209,29 +209,30 @@ rabbitmq:
urls:
# PyDis site vars
- site: &DOMAIN "api.pythondiscord.com"
- site_schema: &SCHEMA "https://"
-
- site_bigbrother_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/bigbrother"]
- site_clean_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/clean"]
- site_clean_logs: !JOIN [*SCHEMA, *DOMAIN, "/bot/clean_logs"]
- site_docs_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/docs"]
- site_facts_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/snake_facts"]
- site_hiphopify_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/hiphopify"]
- site_idioms_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/snake_idioms"]
- site_infractions: !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions"]
- site_infractions_user: !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions/user/{user_id}"]
- site_infractions_type: !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions/type/{infraction_type}"]
- site_infractions_by_id: !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions/id/{infraction_id}"]
- site_infractions_user_type_current: !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions/user/{user_id}/{infraction_type}/current"]
- site_names_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/snake_names"]
- site_off_topic_names_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/off-topic-names"]
- site_quiz_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/snake_quiz"]
- site_settings_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/settings"]
- site_special_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/special_snakes"]
- site_tags_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/tags"]
- site_user_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/users"]
- site_user_complete_api: !JOIN [*SCHEMA, *DOMAIN, "/bot/users/complete"]
+ site: &DOMAIN "pythondiscord.com"
+ site_api: &API !JOIN ["api.", *DOMAIN]
+ site_schema: &SCHEMA "https://"
+
+ site_bigbrother_api: !JOIN [*SCHEMA, *API, "/bot/bigbrother"]
+ site_clean_api: !JOIN [*SCHEMA, *API, "/bot/clean"]
+ site_clean_logs: !JOIN [*SCHEMA, *API, "/bot/clean_logs"]
+ site_docs_api: !JOIN [*SCHEMA, *API, "/bot/docs"]
+ site_facts_api: !JOIN [*SCHEMA, *API, "/bot/snake_facts"]
+ site_hiphopify_api: !JOIN [*SCHEMA, *API, "/bot/hiphopify"]
+ site_idioms_api: !JOIN [*SCHEMA, *API, "/bot/snake_idioms"]
+ site_infractions: !JOIN [*SCHEMA, *API, "/bot/infractions"]
+ site_infractions_user: !JOIN [*SCHEMA, *API, "/bot/infractions/user/{user_id}"]
+ site_infractions_type: !JOIN [*SCHEMA, *API, "/bot/infractions/type/{infraction_type}"]
+ site_infractions_by_id: !JOIN [*SCHEMA, *API, "/bot/infractions/id/{infraction_id}"]
+ site_infractions_user_type_current: !JOIN [*SCHEMA, *API, "/bot/infractions/user/{user_id}/{infraction_type}/current"]
+ site_names_api: !JOIN [*SCHEMA, *API, "/bot/snake_names"]
+ site_off_topic_names_api: !JOIN [*SCHEMA, *API, "/bot/off-topic-names"]
+ site_quiz_api: !JOIN [*SCHEMA, *API, "/bot/snake_quiz"]
+ site_settings_api: !JOIN [*SCHEMA, *API, "/bot/settings"]
+ site_special_api: !JOIN [*SCHEMA, *API, "/bot/special_snakes"]
+ site_tags_api: !JOIN [*SCHEMA, *API, "/bot/tags"]
+ site_user_api: !JOIN [*SCHEMA, *API, "/bot/users"]
+ site_user_complete_api: !JOIN [*SCHEMA, *API, "/bot/users/complete"]
# Env vars
deploy: !ENV "DEPLOY_URL"
@@ -279,7 +280,7 @@ anti_spam:
links:
interval: 10
- max: 4
+ max: 20
mentions:
interval: 10