Add CardsAgainstHumanity module

This commit is contained in:
dave 2015-06-23 11:58:19 -07:00
parent d7d63b65a2
commit 32d5544900
4 changed files with 1590 additions and 0 deletions

View File

@ -0,0 +1,10 @@
:mod:`CardsAgainstHumanity` --- CaH in IRC
==========================================
Class Reference
---------------
.. automodule:: pyircbot.modules.CardsAgainstHumanity
:members:
:undoc-members:
:show-inheritance:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,276 @@
_? There's an app for that.
Why can't I sleep at night?
What's that smell?
I got 99 problems but _ ain't one.
Maybe she's born with it. Maybe it's _.
What's the next Happy Meal© toy?
Anthropologists have recently discovered a primitive tribe that worships _.
It's a pity that kids these days are all getting involved with _.
During Picasso's often-overlooked Brown Period, he produced hundreds of paintings of _.
Alternative medicine is now embracing the curative powers of _.
And the Academy Award for _ goes to _.
What's that sound?
What ended my last relationship?
MTV's new reality show features eight washed-up celebrities living with _.
I drink to forget _.
I'm sorry professor, but I couldn't complete my homework because of _.
What is Batman's guilty pleasure?
This is the way the world ends <br> This is the way the world ends <br> Not with a bang but with _.
What's a girl's best friend?
TSA guidelines now prohibit _ on airplanes.
_. That's how I want to die.
For my next trick, I will pull _ out of _.
In the new Disney Channel Original Movie, Hannah Montana struggles with _ for the first time.
_ is a slippery slope that leads to _.
What does Dick Cheney prefer?
Dear Abby, I'm having some trouble with _ and would like your advice.
Instead of coal, Santa now gives the bad children _.
What's the most emo?
In 1,000 years when paper money is but a distant memory, _ will be our currency.
What's the next superhero/sidekick duo?
In M. Night Shyamalan's new movie, Bruce Willis discovers that _ had really been _ all along.
A romantic, candlelit dinner would be incomplete without _.
_. Becha can't have just one!
White people like _.
_. High five, bro.
Next from J.K. Rowling: Harry Potter and the Chamber of _.
BILLY MAYS HERE FOR _.
In a world ravaged by _, our only solace is _.
War! What is it good for?
During sex, I like to think about _.
What are my parents hiding from me?
What will always get you laid?
In L.A. County Jail, word is you can trade 200 cigarettes for _.
What did I bring back from Mexico?
What don't you want to find in your Chinese food?
What will I bring back in time to convince people that I am a powerful wizard?
How am I maintaining my relationship status?
_. It's a trap!
Coming to Broadway this season, _: The Musical.
While the United States raced the Soviet Union to the moon, the Mexican government funneled millions of pesos into research on _.
After the earthquake, Sean Penn brought _ to the people of Haiti.
Next on ESPN2, the World Series of _.
Step 1: _. Step 2: _. Step 3: Profit.
Rumor has it that Vladimir Putin's favorite dish is _ stuffed with _.
But before I kill you, Mr. Bond, I must show you _.
What gives me uncontrollable gas?
What do old people smell like?
The class field trip was completely ruined by _.
When Pharaoh remained unmoved, Moses called down a Plague of _.
What's my secret power?
What's there a ton of in heaven?
What would grandma find disturbing, yet oddly charming?
I never truly understood _ until I encountered _.
What did the U.S. airdrop to the children of Afghanistan?
What helps Obama unwind?
What did Vin Diesel eat for dinner?
_: good to the last drop.
Why am I sticky?
What gets better with age?
_: kid-tested, mother-approved.
What's the crustiest?
What's Teach for America using to inspire inner city students to succeed?
Studies show that lab rats navigate mazes 50% faster after being exposed to _.
Life for American Indians was forever changed when the White Man introduced them to _.
Make a haiku.
I do not know with what weapons World War III will be fought, but World War IV will be fought with _.
Why do I hurt all over?
What am I giving up for Lent?
In Michael Jackson's final moments, he thought about _.
In an attempt to reach a wider audience, the Smithsonian Museum of Natural History has opened an interactive exhibit on _.
When I am President of the United States, I will create the Department of _.
Lifetime&copy; presents _, the story of _.
When I am a billionaire, I shall erect a 50-foot statue to commemorate _.
When I was tripping on acid, _ turned into _.
That's right, I killed _. How, you ask? _.
What's my anti-drug?
_ + _ = _.
What never fails to liven up the party?
What's the new fad diet?
Major League Baseball has banned _ for giving players an unfair advantage.
My plan for world domination begins with _.
The CIA now interrogates enemy agents by repeatedly subjecting them to _.
Dear Sir or Madam, We regret to inform you that the Office of _ has denied your request for _
In Rome, there are whisperings that the Vatican has a secret room devoted to _.
Science will never explain _.
When all else fails, I can always masturbate to _.
I learned the hard way that you can't cheer up a grieving friend with _.
In its new tourism campaign, Detroit proudly proclaims that it has finally eliminated _.
An international tribunal has found _ guilty of _.
The socialist governments of Scandinavia have declared that access to _ is a basic human right.
In his new self-produced album, Kanye West raps over the sounds of _.
What's the gift that keeps on giving?
Next season on Man vs. Wild, Bear Grylls must survive in the depths of the Amazon with only _ and his wits.
When I pooped, what came out of my butt?
In the distant future, historians will agree that _ marked the beginning of America's decline.
In a pinch, _ can be a suitable substitute for _.
What has been making life difficult at the nudist colony?
Michael Bay's new three-hour action epic pits _ against _.
And I would have gotten away with it, too, if it hadn't been for _.
What brought the orgy to a grinding halt?
During his midlife crisis, my dad got really into _.
_ would be woefully incomplete without _.
My new favorite porn star is Joey &#34;_&#34; McGee.
Before I run for president, I must destroy all evidence of my involvement with _.
This is your captain speaking. Fasten your seatbelts and prepare for _.
In his newest and most difficult stunt, David Blaine must escape from _.
The Five Stages of Grief: denial, anger, bargaining, _, and acceptance.
My mom freaked out when she looked at my browser history and found _.com/_.
I went from _ to _, all thanks to _.
Members of New York's social elite are paying thousands of dollars just to experience _.
This month's Cosmo: &#34;Spice up your sex life by bringing _ into the bedroom.&#34;
Little Miss Muffet Sat on a tuffet, Eating her curds and _.
If God didn't want us to enjoy _, he wouldn't have given us _.
My country, 'tis of thee, sweet land of _.
After months of debate, the Occupy Wall Street General Assembly could only agree on &#34;More _!&#34;
I spent my whole life working toward _, only to have it ruined by _.
Next time on Dr. Phil: How to talk to your child about _.
Only two things in life are certain: death and _.
Everyone down on the ground! We don't want to hurt anyone. We're just here for _.
The healing process began when I joined a support group for victims of _.
The votes are in, and the new high school mascot is _.
Charades was ruined for me forever when my mom had to act out _.
Before _, all we had was _.
Tonight on 20/20: What you don't know about _ could kill you.
You haven't truly lived until you've experienced _ and _ at the same time.
D&D 4.0 isn't real D&D because of the _.
It's a D&D retroclone with _ added.
Storygames aren't RPGs because of the _.
The Slayer's Guide to _.
Worst character concept ever: _, but with _.
Alightment: Chaotic _
It's a D&D retroclone with _ added.
What made the paladin fall? _
The portal leads to the quasi-elemental plane of _.
The Temple of Elemental _.
Pathfinder is basically D&D _ Edition.
_ : The Storytelling Game.
People are wondering why Steve Jackson published GURPS _.
Linear Fighter, Quadratic _.
You start with 1d4 _ points.
Back when I was 12 and I was just starting playing D&D, the game had _.
Big Eyes, Small _.
In the grim darkness of the future there is only _.
My innovative new RPG has a stat for _.
A true gamer has no problem with _.
Elminster cast a potent _ spell and then had sex with _.
The Deck of Many _.
You are all at a tavern when _ approach you.
For the convention I cosplayed as Sailor Moon, except with _.
The worst part of Grave of the Fireflies is all the _.
In the Evangelion remake, Shinji has to deal with _.
Worst anime convention purchase ever? _.
While powering up Vegeta screamed, _!
You evaded my _ attack. Most impressive.
I downloaded a doujin where _ got into _.
The magical girl found out that the Power of Love is useless against _.
The Japanese government has spent billions of yen researching _.
In the dubbed version they changed _ into _.
_ is Best Pony.
The _ of Haruhi Suzumiya.
The new thing in Akihabara is fetish cafes where you can see girls dressed up as _.
Your drill can pierce _!
Avatar: The Last _ bender.
In the name of _ Sailor Moon will punish you!
No harem anime is complete without _.
My boyfriend's a _ now.
The _ of _ has left me in despair!
_.tumblr.com
Somehow they made a cute mascot girl out of _.
Haruko hit Naoto in the head with her bass guitar and _ came out.
After blacking out during New year's Eve, I was awoken by _.
This holiday season, Tim Allen must overcome his fear of _ to save Christmas.
Jesus is _.
Every Christmas, my uncle gets drunk and tells the story about _.
What keeps me warm during the cold, cold, winter?
On the third day of Christmas, my true love gave to me: three French hens, two turtle doves, and _.
Wake up, America. Christmas is under attack by secular liberals and their _.
We got the third rope, now where's the fourth?
Tonights main event, _ vs. _.
Tackle, Dropdown, _.
Christopher Daniels is late on his _.
Instead of booking _, they should have booked _.
Genius is 10% inspiration, 90% _.
They found _ in the dumpster behind _.
The best thing I ever got for Christmas was _.
There's no crying in _.
Mastodon! Pterodactyl! Triceratops! Sabretooth Tiger! _!
Don't eat the _.
He did _ with the _!?!
SOOOOO hot, want to touch the _.
Stop looking at me _!
I'm cuckoo for _ puffs.
Silly rabbit, _ are for kids.
Between love and madness lies _.
Instead of chess, the Grim Reaper now gambles for your soul with a game of _.
My father gave his life fighting to protect _ from _.
Why is my throat sore?
_ sparked a city-wide riot that only ended with _.
Im very sorry Mrs. Smith, but Little Billy has tested positive for _.
Instead of beating them, Chris Brown now does _ to women.
Instead of cutting, trendy young emo girls now engage in _.
The definition of rock bottom is gambling away _.
The Mayan prophecies really heralded the coming of _ in 2012.
The next US election will be fought on the key issues of _ against _.
When I was 10 I wrote to Santa wishing for _.
Where or How I met my last signifigant other: _.
_, Never leave home without it.
_. This is my fetish.
David Icke's newest conspiracy theory states that _ caused _.
I did _ so you don't have to!
I need your clothes, your bike, and _.
In a new Cold War retro movie, the red menace tries to conquer the world through the cunning use of _.
In college, our lecturer made us write a report comparing _ to _.
In The Hangover part 3, those four guys have to deal with _, _, and _.
My zombie survival kit includes food, water, and _.
The way to a man's heart is through _.
What was the theme of my second wedding?
What's the newest Japanese craze to head West?
Everybody loves _.
I can only express myself through _.
My new porn DVD was completely ruined by the inclusion of _
My three wishes will be for _, _, and _.
The latest horrifying school shooting was inspired by _.
I got fired because of my not-so-secret obsession over _.
My new favourite sexual position is _
A successful job interview begins with a firm handshake and ends with _.
Lovin' you is easy 'cause you're _.
My life is ruled by a vicious cycle of _ and _.
The blind date was going horribly until we discovered our shared interest in _.
_. Awesome in theory, kind of a mess in practice.
I'm not like the rest of you. I'm too rich and busy for _.
In the seventh circle of Hell, sinners must endure _ for all eternity.
_: Hours of fun. Easy to use. Perfect for _!
What left this stain on my couch?
Call the law offices of Goldstein & Goldstein, because no one should have to tolerate _ in the workplace.
When you get right down to it, _ is just _.
Turns out that _-Man was neither the hero we needed nor wanted.
As part of his daily regimen, Anderson Cooper sets aside 15 minutes for _.
Money can't buy me love, but it can buy me _.
With enough time and pressure, _ will turn into _.
And what did you bring for show and tell?
During high school, I never really fit in until I found _ club.
Hey, baby, come back to my place and I'll show you _.
After months of practice with _, I think I'm finally ready for _.
To prepare for his upcoming role, Daniel Day-Lewis immersed himself in the world of _.
Finally! A service that delivers _ right to your door.
My gym teacher got fired for adding _ to the obstacle course.
Having problems with _? Try _!
As part of his contract, Prince won't perform without _ in his dressing room.
Listen, son. If you want to get involved with _, I won't stop you. Just steer clear of _.
I just met you and this is crazy, but here's _, so _ maybe
It's only _ if you get caught!
_: The Next Generation
Terminator 4: _
Disney presents _ on ice!
_. The other white meat.
A _ a day keeps the _ away.
I'm sweating like a _ at a _.
I love the smell of _ in the morning.
You're not gonna believe this, but _.
_. All the cool kids are doing it.
So I was _ in my cubicle at work, and suddenly _!
Baskin Robbins just added a 32nd flavor: _!
I can drive and ____ at the same time.
_ ain't nothin' to fuck wit'!

View File

@ -0,0 +1,256 @@
#!/usr/bin/env python
"""
.. module::CardsAgainstHumanity
:synopsis: Cards against Humanity, in IRC. Cards against IRC?
.. moduleauthor:: Nick Krichevsky <nick@ollien.com>
"""
from pyircbot.modulebase import ModuleBase,ModuleHook
import yaml
import os
import time
from threading import Timer
from operator import itemgetter
from random import choice
class CardsAgainstHumanity(ModuleBase):
def __init__(self, bot, moduleName):
# init the base module
ModuleBase.__init__(self, bot, moduleName);
self.hooks=[ModuleHook("PRIVMSG", self.scramble)]
self.loadConfig()
# Dictionary
self.whitesFile = open(self.getFilePath("answers.txt"),'r')
self.blacksFile = open(self.getFilePath("questions.txt"),'r')
self.whites = [line.rstrip() for line in self.whitesFile]
self.blacks = [line.rstrip() for line in self.blacksFile]
self.currentBlack = ""
self.whitesFile.close()
self.blacksFile.close()
self.log.info("CAH: Loaded."+str(len(self.whites))+" White Cards "+str(len(self.blacks))+" Black Cards")
# Per channel games
self.games = {}
def scramble(self, args, prefix, trailing):
channel = args[0]
if channel[0] == "#":
if not channel in self.games:
self.games[channel]=cardsGame(self, channel,self.whites,self.blacks)
self.games[channel].stuff(args, prefix, trailing)
def ondisable(self):
self.log.info("CAH: Unload requested, ending games...")
# for game in self.games:
# self.games[game].gameover()
class cardsGame:
def __init__(self, master, channel,whites,blacks):
self.master = master
self.channel = channel
# Running?
self.running = False
# Current word
# self.message = 'xmopxshell has downs'
self.players = {}
self.timers = {}
self.whites = whites
self.blacks = blacks
self.lastCzar = -1
self.czar = ""
self.started = False
self.active = False
self.allowPick = 0
self.choices = {}
self.czarTimer = None
def stuff(self, args, prefix, trailing):
prefix = self.master.bot.decodePrefix(prefix)
sender = prefix.nick
if self.master.bot.messageHasCommand(".joinGame", trailing):
self.join(sender)
elif self.master.bot.messageHasCommand(".ready",trailing):
result = self.markReady(sender)
if result:
self.started = True
self.master.bot.act_PRIVMSG(self.channel,"All players are ready!")
for player in self.players:
self.master.bot.act_PRIVMSG(player,"ITS TIME TO D-D-D-D-D-DUEL!")
self.players[player]=[]
for player in self.players:
self.deal(player)
self.sendCards(player)
self.active = True
self.makeTurn()
elif self.master.bot.messageHasCommand(".pick",trailing):
if self.active:
if sender != self.czar:
print(sender,self.czar)
print(sender != self.czar)
if self.allowPick > 0:
if sender in self.players:
cards = trailing.split(' ')[1:]
if len(cards)==self.allowPick:
if self.checkBounds(cards):
if sender not in self.choices:
cardChoices = [self.players[sender][int(index)] for index in cards]
print(cardChoices)
self.choices[sender] = cardChoices
self.removeAndReplenishCards(sender, cardChoices)
self.sendCards(sender)
del self.choices[sender]
if sender in timers:
self.timers[sender].cancel()
if self.allDrawn():
self.readChoices()
self.master.bot.act_PRIVMSG(self.channel,self.czar+"! Please choose the winner!")
czarTimer = Timer(180,self.kick,(self.czar,"taking too long to pick a choice. The next turn iwll be made."))
self.makeTurn()
else:
self.master.bot.act_PRIVMSG(self.channel,sender+", you picked a card that was out of the range. Please don't do that.")
else:
self.master.bot.act_PRIVMSG(self.channel,sender+", you picked "+str(len(cards))+" cards. You were supposed to pick "+str(self.allowPick))
elif self.master.bot.messageHasCommand(".choose",trailing):
if sender==self.czar:
choice = trailing.split()[1:]
if len(choice)==1:
if self.checkChoiceBounds(int(choice[0])):
self.master.bot.act_PRIVMSG(self.channel,list(self.choices.keys())[int(choice[0])]+", you won the round!")
if self.czarTimer!=None:
self.czarTimer.cancel()
self.makeTurn()
else:
self.master.bot.act_PRIVMSG(self.channel,sender+", your choice was out of the range. Please don't do that.")
else:
self.master.bot.act_PRIVMSG(self.channel,sender+", you picked "+str(len(choice))+" "+" winners. You were only supposed to pick 1.")
elif self.master.bot.messageHasCommand('.leave',trailing):
if sender in self.players:
self.kick(sender,'choosing to leave the game you dolt')
if sender is self.czar:
self.makeTurn()
def join(self,nick):
if not self.started:
if nick not in self.players:
self.players[nick]=False
self.master.bot.act_PRIVMSG(self.channel, nick+" has joined the game! | The players currently are "+str(self.players))
else:
print("the game has already started!")
self.master.bot.act_PRIVMSG(self.channel,"The game has already started!")
def markReady(self,nick):
if not self.started:
if nick in self.players:
self.players[nick]=True
for player in self.players:
print(player)
if not self.players[player]:
print (player+" not ready")
return False
return True
else:
self.master.bot.act_PRIVMSG(self.channel, "You are not in the game! Type .joinGame!")
else:
print("game has already started!")
self.master.bot.act_PRIVMSG(self.channel,"The game has already started!")
def deal(self,nick):
self.players[nick] = [self.pickWhite() for i in range (7)]
def pickWhite(self):
card = choice(self.whites)
self.whites.remove(card)
return card
def pickBlack(self):
card = choice(self.blacks)
self.blacks.remove(card)
return card
def sendCards(self,nick):
cards = ""
for card in self.players[nick]:
cards+=str(self.players[nick].index(card))+". "
cards+=card+" "
self.master.bot.act_PRIVMSG(nick,"Your cards are "+cards)
def readCard(self,card):
count = card.count('_')
if count == 0:
if 'haiku' in card:
count = 3
else:
count = 1
self.master.bot.act_PRIVMSG(self.channel,"The black card is \""+card+"\" Pick "+str(count))
return count
def pickCzar(self):
index = self.lastCzar+1
if index < len(self.players):
self.lastCzar = index
return index
else:
self.lastCzar = 0
return 0
def announceCzar(self):
self.master.bot.act_PRIVMSG(self.channel,"The Czar is "+self.czar+"!")
def checkBounds(self,cards):
for item in cards:
if int(item)>6 or int(item)<0:
return False
return True
def checkChoiceBounds(self,choice):
if choice<0 or choice>len(self.choices)-1:
return False
return True
def makeTurn(self):
self.choices.clear()
card = self.pickBlack()
self.timers.clear()
self.currentBlack = card
self.allowPick = self.readCard(card)
self.lastCzar = self.pickCzar()
self.czar = list(self.players.keys())[self.lastCzar]
print (self.lastCzar,self.czar)
for player in self.players:
if player!=self.czar:
self.timers[player] = Timer(180,self.kick,(player,"taking more than 180 seconds for their turn."))
self.timers[player].start()
self.announceCzar()
def kick(self,nick,reason):
del self.players[nick]
if nick in self.timers:
self.timers[nick].cancel()
del self.timers[nick]
self.master.bot.act_PRIVMSG(self.channel,nick+" has been kicked due to "+reason)
if len(self.players)<=1:
self.master.bot.act_PRIVMSG(self.channel,"The game is being shut down due to having <=1 players")
self.started = False
self.active = False
for timer in self.timers:
timer.cancel()
self.timers.clear()
self.players.clear()
def removeAndReplenishCards(self,nick,cards):
for card in cards:
self.players[nick].remove(card)
self.players[nick].append(self.pickWhite())
def readChoices(self):
if '_' in self.currentBlack:
for player in list(self.choices.keys()):
cardInstance = str(list(self.choices.keys()).index(player))+". "+self.currentBlack
cardInstance = list(cardInstance) #do this as opposed to space to preserve spaces
for choice in self.choices[player]:
for char in cardInstance:
if char=='_':
print(char)
choice = choice.replace('.','')
cardInstance[cardInstance.index(char)] = choice
break
self.master.bot.act_PRIVMSG(self.channel,''.join(cardInstance))
else:
for player in self.choices:
self.master.bot.act_PRIVMSG(self.channel,self.currentBlack+' '+' '.join(self.choices[player]))
def allDrawn(self):
for player in self.players:
if player not in self.choices:
if player != self.czar:
return False
return True