added slur.py
This commit is contained in:
parent
79d161d829
commit
3155be4995
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,4 +8,5 @@ logs/
|
|||
*.pid
|
||||
*.swp
|
||||
*.txt
|
||||
*.db-journal
|
||||
tourettes.py
|
||||
|
|
45
modules/slur.py
Normal file
45
modules/slur.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Actions for the Racial Slurs Database table.
|
||||
All data comes from http://www.rsdb.org/.
|
||||
"""
|
||||
import random
|
||||
import sqlite3
|
||||
|
||||
from module import commands
|
||||
|
||||
|
||||
def setup(bot):
|
||||
con = bot.db.connect()
|
||||
cur = con.cursor()
|
||||
try:
|
||||
cur.execute("SELECT * FROM slur").fetchone()
|
||||
except OperationalError:
|
||||
cur.execute("CREATE TABLE slur("
|
||||
"slur TEXT,"
|
||||
"race TEXT,"
|
||||
"description TEXT")
|
||||
con.commit()
|
||||
con.close()
|
||||
|
||||
|
||||
@commands("slur")
|
||||
def slur(bot, trigger):
|
||||
"""
|
||||
Prints a random racial slur from the Racial Slurs Database.
|
||||
|
||||
[RACE] - specifies a particular race to pick on.
|
||||
"""
|
||||
if trigger.group(2):
|
||||
slur = bot.db.execute(
|
||||
"SELECT * FROM `slur` WHERE `race` = ? COLLATE NOCASE " \
|
||||
+ "ORDER BY RANDOM() LIMIT 1", (trigger.group(2),)).fetchone()
|
||||
else:
|
||||
slur = bot.db.execute(
|
||||
"SELECT * FROM `slur` ORDER BY RANDOM() LIMIT 1").fetchone()
|
||||
if not slur:
|
||||
return bot.msg("Could not find slur.")
|
||||
msg = f"[\x0304SLUR\x03] \x0310Slur\x03: \x0312{slur[0]}\x03 | "
|
||||
msg += f"\x0310Race\x03: \x0312{slur[1]}\x03 | "
|
||||
msg += f"\x0310Description\x03: \x0312{slur[2]}\x03"
|
||||
bot.msg(msg)
|
Loading…
Reference in New Issue
Block a user