Skip to content

Commit

Permalink
Added 3rd party word generator for taboo game
Browse files Browse the repository at this point in the history
  • Loading branch information
sometimesok committed Dec 6, 2020
1 parent e28ca95 commit 5f6604b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
7 changes: 4 additions & 3 deletions ISS/contrib/taboo/__init__.py
Expand Up @@ -7,16 +7,17 @@
'violation_duration': timedelta(days=1),
'ban_reason_tmpl': 'You said the taboo phrase "%(phrase)s"!',
'reregister_cooldown': timedelta(days=1),
'min_posts_to_reg': 100,
'min_age_to_reg': timedelta(days=28),
'min_posts_to_reg': 50,
'min_age_to_reg': timedelta(days=14),
'time_to_inactivity': timedelta(days=7),
'post_msg_tmpl': '\n\n[b]User was banned for saying the taboo phrase "%(phrase)s"![/b]',
'base_path': '^taboo/',
'gulp_dir': os.path.dirname(os.path.realpath(__file__)) + '/static-src',
'usertitle_punishment': 'victim of incest',
'usertitle_reward': 'motherfucker',
'usertitle_duration': timedelta(days=14),
'phrases': ['adult', 'aeroplane', 'air', 'aircraft carrier', 'airforce', 'airport', 'album', 'alphabet', 'apple', 'arm', 'army', 'baby', 'baby', 'backpack', 'balloon', 'banana', 'bank', 'barbecue', 'bathroom', 'bathtub', 'bed', 'bed', 'bee', 'bible', 'bible', 'bird', 'bomb', 'book', 'boss', 'bottle', 'bowl', 'box', 'boy', 'brain', 'bridge', 'butterfly', 'button', 'cappuccino', 'car', 'car-race', 'carpet', 'carrot', 'cave', 'chair', 'chess board', 'chief', 'child', 'chisel', 'chocolates', 'church', 'church', 'circle', 'circus', 'circus', 'clock', 'clown', 'coffee', 'coffee-shop', 'comet', 'compact disc', 'compass', 'computer', 'crystal', 'cup', 'cycle', 'data base', 'desk', 'diamond', 'dress', 'drill', 'drink', 'drum', 'dung', 'ears', 'earth', 'egg', 'electricity', 'elephant', 'eraser', 'explosive', 'eyes', 'family', 'fan', 'feather', 'festival', 'film', 'finger', 'fire', 'floodlight', 'flower', 'foot', 'fork', 'freeway', 'fruit', 'fungus', 'game', 'garden', 'gas', 'gate', 'gemstone', 'girl', 'gloves', 'god', 'grapes', 'guitar', 'hammer', 'hat', 'hieroglyph', 'highway', 'horoscope', 'horse', 'hose', 'ice', 'ice-cream', 'insect', 'jet fighter', 'junk', 'kaleidoscope', 'kitchen', 'knife', 'leather jacket', 'leg', 'library', 'liquid', 'magnet', 'man', 'map', 'maze', 'meat', 'meteor', 'microscope', 'milk', 'milkshake', 'mist', 'money $$$$', 'monster', 'mosquito', 'mouth', 'nail', 'navy', 'necklace', 'needle', 'onion', 'paintbrush', 'pants', 'parachute', 'passport', 'pebble', 'pendulum', 'pepper', 'perfume', 'pillow', 'plane', 'planet', 'pocket', 'post-office', 'potato', 'printer', 'prison', 'pyramid', 'radar', 'rainbow', 'record', 'restaurant', 'rifle', 'ring', 'robot', 'rock', 'rocket', 'roof', 'room', 'rope', 'saddle', 'salt', 'sandpaper', 'sandwich', 'satellite', 'school', 'sex', 'ship', 'shoes', 'shop', 'shower', 'signature', 'skeleton', 'slave', 'snail', 'software', 'solid', 'space shuttle', 'spectrum', 'sphere', 'spice', 'spiral', 'spoon', 'sports-car', 'spot light', 'square', 'staircase', 'star', 'stomach', 'sun', 'sunglasses', 'surveyor', 'swimming pool', 'sword', 'table', 'tapestry', 'teeth', 'telescope', 'television', 'tennis racquet', 'thermometer', 'tiger', 'toilet', 'tongue', 'torch', 'torpedo', 'train', 'treadmill', 'triangle', 'tunnel', 'typewriter', 'umbrella', 'vacuum', 'vampire', 'videotape', 'vulture', 'water', 'weapon', 'web', 'wheelchair', 'window', 'woman', 'worm', 'x-ray']
'phrases': ['adult', 'aeroplane', 'air', 'aircraft carrier', 'airforce', 'airport', 'album', 'alphabet', 'apple', 'arm', 'army', 'baby', 'baby', 'backpack', 'balloon', 'banana', 'bank', 'barbecue', 'bathroom', 'bathtub', 'bed', 'bed', 'bee', 'bible', 'bible', 'bird', 'bomb', 'book', 'boss', 'bottle', 'bowl', 'box', 'boy', 'brain', 'bridge', 'butterfly', 'button', 'cappuccino', 'car', 'car-race', 'carpet', 'carrot', 'cave', 'chair', 'chess board', 'chief', 'child', 'chisel', 'chocolates', 'church', 'church', 'circle', 'circus', 'circus', 'clock', 'clown', 'coffee', 'coffee-shop', 'comet', 'compact disc', 'compass', 'computer', 'crystal', 'cup', 'cycle', 'data base', 'desk', 'diamond', 'dress', 'drill', 'drink', 'drum', 'dung', 'ears', 'earth', 'egg', 'electricity', 'elephant', 'eraser', 'explosive', 'eyes', 'family', 'fan', 'feather', 'festival', 'film', 'finger', 'fire', 'floodlight', 'flower', 'foot', 'fork', 'freeway', 'fruit', 'fungus', 'game', 'garden', 'gas', 'gate', 'gemstone', 'girl', 'gloves', 'god', 'grapes', 'guitar', 'hammer', 'hat', 'hieroglyph', 'highway', 'horoscope', 'horse', 'hose', 'ice', 'ice-cream', 'insect', 'jet fighter', 'junk', 'kaleidoscope', 'kitchen', 'knife', 'leather jacket', 'leg', 'library', 'liquid', 'magnet', 'man', 'map', 'maze', 'meat', 'meteor', 'microscope', 'milk', 'milkshake', 'mist', 'money $$$$', 'monster', 'mosquito', 'mouth', 'nail', 'navy', 'necklace', 'needle', 'onion', 'paintbrush', 'pants', 'parachute', 'passport', 'pebble', 'pendulum', 'pepper', 'perfume', 'pillow', 'plane', 'planet', 'pocket', 'post-office', 'potato', 'printer', 'prison', 'pyramid', 'radar', 'rainbow', 'record', 'restaurant', 'rifle', 'ring', 'robot', 'rock', 'rocket', 'roof', 'room', 'rope', 'saddle', 'salt', 'sandpaper', 'sandwich', 'satellite', 'school', 'sex', 'ship', 'shoes', 'shop', 'shower', 'signature', 'skeleton', 'slave', 'snail', 'software', 'solid', 'space shuttle', 'spectrum', 'sphere', 'spice', 'spiral', 'spoon', 'sports-car', 'spot light', 'square', 'staircase', 'star', 'stomach', 'sun', 'sunglasses', 'surveyor', 'swimming pool', 'sword', 'table', 'tapestry', 'teeth', 'telescope', 'television', 'tennis racquet', 'thermometer', 'tiger', 'toilet', 'tongue', 'torch', 'torpedo', 'train', 'treadmill', 'triangle', 'tunnel', 'typewriter', 'umbrella', 'vacuum', 'vampire', 'videotape', 'vulture', 'water', 'weapon', 'web', 'wheelchair', 'window', 'woman', 'worm', 'x-ray'],
'wordnik_API_key': 'null'
}

from ISS.contrib.taboo import hooks
23 changes: 21 additions & 2 deletions ISS/contrib/taboo/models.py
@@ -1,5 +1,7 @@

import random
import requests
import html
from datetime import timedelta

from django.db import models, transaction
Expand Down Expand Up @@ -71,9 +73,26 @@ def _get_candidate_marks(self):

return candidates

def _get_taboo_phrase(self):
API_Key = iss_utils.get_ext_config(EXT, 'wordnik_API_key')

if API_Key == 'null':
return random.choice(iss_utils.get_ext_config(EXT, 'phrases'))

for x in range(5):
# minDictionaryCount at 50 seems to bring a pretty good word list, going higher results in more 404s
url = 'https://api.wordnik.com/v4/words.json/randomWord?hasDictionaryDef=true&' \
'includePartOfSpeech=noun%2Cverb&minDictionaryCount=50&minLength=3&api_key=' \
+ API_Key

response = requests.get(url)
if response.status_code == 200:
return html.escape(response.json()['word'])

return random.choice(iss_utils.get_ext_config(EXT, 'phrases'))

def choose_mark_and_phrase(self):
self.phrase = random.choice(
iss_utils.get_ext_config(EXT, 'phrases'))
self.phrase = self._get_taboo_phrase()
candidates = self._get_candidate_marks()
ccount = len(candidates)

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -8,6 +8,7 @@ django-houston==0.3.0
email-normalize==0.2.1
bbcode==1.0.33
django-recaptcha2==1.4.1
requests==2.22.0

# Dev dependencies
django-debug-toolbar==2.1
Expand Down

0 comments on commit 5f6604b

Please sign in to comment.