added --slur and --race arguments to slur module
This commit is contained in:
parent
57502f3c9f
commit
a2554f3c2f
|
@ -5,6 +5,7 @@ All data comes from http://www.rsdb.org/.
|
|||
"""
|
||||
import random
|
||||
import sqlite3
|
||||
import argparse
|
||||
|
||||
from module import commands
|
||||
|
||||
|
@ -28,12 +29,22 @@ def slur(bot, trigger):
|
|||
"""
|
||||
Prints a random racial slur from the Racial Slurs Database.
|
||||
|
||||
[RACE] - specifies a particular race to pick on.
|
||||
-r, --race - specifies a particular race to pick on.
|
||||
-s, --slur - specifies a particular slur to pick.
|
||||
"""
|
||||
if trigger.group(2):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-r", "--race", type=str)
|
||||
parser.add_argument("-s", "--slur", type=str)
|
||||
args = parser.parse_args(trigger.group[3:])
|
||||
|
||||
if args.race:
|
||||
slur = bot.db.execute(
|
||||
"SELECT * FROM `slur` WHERE `race` = ? COLLATE NOCASE " \
|
||||
+ "ORDER BY RANDOM() LIMIT 1", (trigger.group(2),)).fetchone()
|
||||
+ "ORDER BY RANDOM() LIMIT 1", (args.race,)).fetchone()
|
||||
elif args.slur:
|
||||
slur = bot.db.execute(
|
||||
"SELECT * FROM `slur` WHERE `slur` LIKE ? COLLATE NOCASE " \
|
||||
+ "LIMIT 1", (f"%{args.slur}%",)).fetchone()
|
||||
else:
|
||||
slur = bot.db.execute(
|
||||
"SELECT * FROM `slur` ORDER BY RANDOM() LIMIT 1").fetchone()
|
||||
|
|
Loading…
Reference in New Issue
Block a user