phenny/modules/chillmeter.py

122 lines
2.5 KiB
Python
Raw Normal View History

#!/usr/bin/python2
"""
chillmeter.py - .chill measures chill level of the channel
author: Casey Link <unnamedrambler@gmail.com>
so chill bro.
"""
import random, time
# chill decay rate per minute
chill_decay_rate = 5
# words that make the place chill
chill_words = [
"chill",
"bro",
"fist bump",
"fistbump",
"natty",
"natties",
"head nod",
"she said",
"keystone",
"smirnoff",
2011-09-08 16:18:34 -04:00
"sandwhich",
2011-09-08 16:33:20 -04:00
"lax pinny",
2011-09-08 16:18:34 -04:00
"lacrosse",
2011-09-08 16:33:20 -04:00
"a bowl",
"slampiece"
]
2011-09-08 16:38:04 -04:00
# words that unchill the place
unchill_words = [
"dude",
"suck",
"desi",
"lame",
"imageshack",
"microsoft",
"btreecat",
"homework",
"project",
"test",
"exam",
"4chan"
]
# all things chill
chill_things = [
("natty", "natties"),
("smirnoff ice", "smirnoffs"),
("bong hit", "bong hits"),
("case of keystone", "cases of keystone"),
("fist bump", "fist bumps"),
("head nod", "head nods"),
("bro", "bros")
]
# keeps a finger on the pulse of the chillness
def measure(phenny, input):
2011-09-08 16:28:58 -04:00
chill = measure.channels.get(input.sender, 0)
now = time.time()
if now - measure.last_tick > 60:
measure.last_tick = now
2011-09-08 16:28:58 -04:00
chill -= chill_decay_rate
chill = max(0, chill)
measure.channels[input.sender] = chill
if ".chill" in input:
return # dont self count
for w in chill_words:
if w in input.lower():
2011-09-08 16:28:58 -04:00
chill += 1
2011-09-08 16:38:04 -04:00
for w in unchill_words:
if w in input.lower():
chill -= 1
2011-09-08 16:28:58 -04:00
measure.channels[input.sender] = chill
measure.rule = r'.*'
measure.priority = 'low'
measure.last_tick = time.time()
2011-09-08 16:28:58 -04:00
measure.channels = {}
def chill(phenny, input):
2011-09-08 16:28:58 -04:00
level = measure.channels.get(input.sender, 0)
n = random.randint(1,2)
items = []
for i in range(n):
if level == 0:
amount = random.randint(5, 10)
else:
amount = random.randint(1, level)
item = random.choice(chill_things)
if amount == 1:
item = item[0] # singular
else:
item = item[1] # plural
items.append("%s %s" % (amount, item))
item_str = ", ".join(items)
print level, item_str
if level == 0:
message = "WARNING: CHILL LEVEL IS DANGEROUSLY LOW. RECOMMEND %s" % (item_str.upper())
else:
message = "chill level is currently: %s" % (item_str)
phenny.say(message)
chill.commands = ['chill']
chill.priority = 'low'
if __name__ == '__main__':
print __doc__.strip()