aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Kingsley McDonald <[email protected]>2018-08-01 11:17:22 +0000
committerGravatar Johannes Christ <[email protected]>2018-08-01 11:17:22 +0000
commit9d81d9c768a61384b4d406ccc0a1bc96c2e3bafd (patch)
treea150edc74ff43bd776a1a76d1327475a91ce4c5b
parentMerge branch 'feature/reddit-channel' into 'master' (diff)
Add Site cog.
-rw-r--r--bot/__main__.py1
-rw-r--r--bot/cogs/site.py98
-rw-r--r--bot/constants.py1
-rw-r--r--config-default.yml47
4 files changed, 124 insertions, 23 deletions
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/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..cfe456fbe 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"