chillmeter: add weighting

master
mutantmonkey 2011-09-08 18:22:45 -04:00
parent 0194837708
commit dd0ade6136
1 changed files with 41 additions and 43 deletions

View File

@ -2,6 +2,7 @@
""" """
chillmeter.py - .chill measures chill level of the channel chillmeter.py - .chill measures chill level of the channel
author: Casey Link <unnamedrambler@gmail.com> author: Casey Link <unnamedrambler@gmail.com>
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
so chill bro. so chill bro.
""" """
@ -11,43 +12,41 @@ import random, time
# chill decay rate per minute # chill decay rate per minute
chill_decay_rate = 5 chill_decay_rate = 5
# words that make the place chill
chill_words = [ chill_words = [
"chill", # words that make the place chill
"bro", ("chill", 1),
"fist bump", ("bro", 1),
"fistbump", ("fist bump", 2),
"natty", ("fistbump", 2),
"natties", ("natty", 1),
"head nod", ("natties", 2),
"she said", ("head nod", 1),
"keystone", ("she said", 1),
"smirnoff", ("keystone", 1),
"sandwhich", ("sandwich", 1),
"lax", ("lax", 2),
"lacrosse", ("lacrosse", 2),
"pinny", ("pinny", 2),
"a bowl", ("bowl", 1),
"slampiece", ("slampiece", 2),
"smirnoff", ("smirnoff", 1),
"ices", ("ices", 1),
"iced" ("iced", 1),
]
# words that unchill the place # words that unchill the place
unchill_words = [ ("dude", -1),
"dude", ("suck", -2),
"suck", ("desi", -1),
"desi", ("lame", -2),
"lame", ("imageshack", -1),
"imageshack", ("microsoft", -1),
"microsoft", ("btreecat", -1),
"btreecat", ("homework", -1),
"homework", ("project", -2),
"project", ("test", -2),
"test", ("exam", -2),
"exam", ("4chan", -1),
"4chan" ("digg", -1),
] ]
# all things chill # all things chill
@ -76,12 +75,8 @@ def measure(phenny, input):
return # dont self count return # dont self count
for w in chill_words: for w in chill_words:
if w in input.lower(): if w[0] in input.lower():
chill += 1 chill += w[1]
for w in unchill_words:
if w in input.lower():
chill -= 1
measure.channels[input.sender] = chill measure.channels[input.sender] = chill
@ -92,6 +87,7 @@ measure.last_tick = time.time()
measure.channels = {} measure.channels = {}
def chill(phenny, input): def chill(phenny, input):
""".chill - Measure the current channel chillness level."""
level = measure.channels.get(input.sender, 0) level = measure.channels.get(input.sender, 0)
n = random.randint(1,2) n = random.randint(1,2)
@ -100,6 +96,8 @@ def chill(phenny, input):
for i in range(n): for i in range(n):
if level == 0: if level == 0:
amount = random.randint(5, 10) amount = random.randint(5, 10)
elif level < 0:
amount = random.randint(10, -level * 2 + 10)
else: else:
amount = random.randint(1, level) amount = random.randint(1, level)
item = random.choice(chill_things) item = random.choice(chill_things)
@ -115,9 +113,9 @@ def chill(phenny, input):
items.append("%s %s" % (amount, item)) items.append("%s %s" % (amount, item))
item_str = ", ".join(items) item_str = ", ".join(items)
print level, item_str #print level, item_str
if level == 0: if level <= 0:
message = "WARNING: CHILL LEVEL IS DANGEROUSLY LOW. RECOMMEND %s" % (item_str.upper()) message = "WARNING: CHILL LEVEL IS DANGEROUSLY LOW. RECOMMEND %s" % (item_str.upper())
else: else:
message = "chill level is currently: %s" % (item_str) message = "chill level is currently: %s" % (item_str)