summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.py51
1 files changed, 36 insertions, 15 deletions
diff --git a/src/main.py b/src/main.py
index b16794d..487acf7 100644
--- a/src/main.py
+++ b/src/main.py
@@ -19,21 +19,40 @@ bot = commands.Bot(command_prefix="Sigmar! ", intents=intents)
async def ping(ctx):
await ctx.send("pong")
[email protected](name="Explain", aliases=["explain", "What's", "what's"])
[email protected](name="Help", aliases=["help"])
+async def help(ctx):
+ await ctx.send('''Sigmar Bot - format Sigmar! [explain | what's | whats]
+ Flags:
+ - !aos: Age of Sigmar wiki [default]
+ - !fantasy: WHFB wiki
+ - !40k: WH40K wiki
+ - !noimage: don't include image in embed
+ - !nolinks: don't include 'see also' links in embed
+ ''')
+
[email protected](name="Explain", aliases=["explain", "What's", "what's", "whats"])
async def explain(ctx, *args):
- args = list(args)
- if args[0].lower() == "!fantasy":
- args.pop(0)
- config["site"] = "https://whfb.lexicanum.com"
- elif args[0].lower() == "!40k":
- args.pop(0)
- config["site"] = "https://wh40k.lexicanum.com"
- elif args[0].lower() == "!aos":
- args.pop(0)
- config["site"] = "https://ageofsigmar.lexicanum.com"
- else:
- config["site"] = "https://ageofsigmar.lexicanum.com"
+ config["site"] = "https://ageofsigmar.lexicanum.com"
+ include_image = True
+ include_links = True
+
+ args = list(args)
+ for arg in args:
+ if arg.startswith("!"):
+ match arg.lower():
+ case "!fantasy":
+ config["site"] = "https://whfb.lexicanum.com"
+ case "!40k":
+ config["site"] = "https://wh40k.lexicanum.com"
+ case "!aos":
+ config["site"] = "https://ageofsigmar.lexicanum.com"
+ case "!noimage":
+ include_image = False
+ case "!nolinks":
+ include_links = False
+ args.remove(arg)
+
query = " ".join([x.replace('"', "") for x in args])
try:
@@ -48,11 +67,13 @@ async def explain(ctx, *args):
string_results = " ".join(str(x) for x in search_content)
- if page_img_link:
+ if page_img_link and include_image:
embed.set_image(url=page_img_link)
embed.add_field(name="Overview", value=page_content, inline=False)
- embed.add_field(name="You May Have Meant", value=string_results, inline=False)
+
+ if include_links:
+ embed.add_field(name="You May Have Meant", value=string_results, inline=False)
await ctx.send(embed=embed)
except scrape_lexicanum.WikiError as e: