Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
Add ASCII check for non-admin commands
Browse files Browse the repository at this point in the history
  • Loading branch information
KOOKIIEStudios committed Nov 9, 2020
1 parent b3b1bd7 commit 32a3df5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ async def handle_character(client, txt_channel, author, msg, message) \
await txt_channel.send("Usage: !character <name>")
return False
character_name = args[1]

# Optional ASCII-check for char name (comment out if undesired)
# Since GMS should only have ASCII names
if not Utils.is_ascii(character_name):
txt_channel.send("Invalid characters detected in character name!")

rows, result = DatabaseHandler.get_character_stats(character_name)
# A tuple is returned, result being false means the database is off and vice versa

Expand Down Expand Up @@ -151,6 +157,12 @@ async def handle_guild(client, txt_channel, author, msg, message) \
await txt_channel.send("Usage: !guild <name>")
return False
guild_name = args[1]

# Optional ASCII-check for guild name (comment out if undesired)
# Since GMS should only have ASCII names
if not Utils.is_ascii(guild_name):
txt_channel.send("Invalid characters detected in guild name!")

rows, result = DatabaseHandler.get_guild_info(guild_name)
if not result: # If the result is false the database is offline
await txt_channel.send(config.DATABASE_OFFLINE_MESSAGE)
Expand Down Expand Up @@ -198,6 +210,11 @@ async def handle_ranking(client, txt_channel, author, msg, message) \
# TODO: Add category list
return False
category = args[1]

# Optional ASCII-check for rank type (comment out if undesired)
if not Utils.is_ascii(category):
txt_channel.send("Invalid characters detected in rank category!")

table, result = DatabaseHandler.get_rankings(category)
if "column" in str(table): # checks if the word "column" is in the table this means the column was not found
await txt_channel.send("Can't find the category")
Expand Down

0 comments on commit 32a3df5

Please sign in to comment.