2011-06-04 11:38:11 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
slogan.py - Phenny Slogan Module
|
|
|
|
Copyright (c) 2011 Dafydd Crosby - http://www.dafyddcrosby.com
|
|
|
|
|
|
|
|
Licensed under the Eiffel Forum License 2.
|
|
|
|
"""
|
|
|
|
|
2012-06-02 01:17:09 -04:00
|
|
|
from tools import GrumbleError
|
2011-06-04 11:38:11 -04:00
|
|
|
import re
|
|
|
|
import web
|
|
|
|
|
|
|
|
uri = 'http://www.sloganizer.net/en/outbound.php?slogan=%s'
|
|
|
|
|
|
|
|
def sloganize(word):
|
2011-09-22 14:17:27 -04:00
|
|
|
bytes = web.get(uri % web.quote(word))
|
2011-06-04 11:38:11 -04:00
|
|
|
return bytes
|
|
|
|
|
|
|
|
def slogan(phenny, input):
|
2013-10-05 19:20:37 -04:00
|
|
|
""".slogan <term> - Come up with a slogan for a term."""
|
|
|
|
|
2011-06-04 11:38:11 -04:00
|
|
|
word = input.group(2)
|
2011-07-28 10:48:40 -04:00
|
|
|
if word is None:
|
|
|
|
phenny.say("You need to specify a word; try .slogan Granola")
|
|
|
|
return
|
2011-07-28 10:55:23 -04:00
|
|
|
|
|
|
|
word = word.strip()
|
2011-06-04 11:38:11 -04:00
|
|
|
slogan = sloganize(word)
|
|
|
|
|
|
|
|
# Remove HTML tags
|
|
|
|
remove_tags = re.compile(r'<.*?>')
|
|
|
|
slogan = remove_tags.sub('', slogan)
|
|
|
|
|
|
|
|
if not slogan:
|
2012-06-02 01:17:09 -04:00
|
|
|
raise GrumbleError("Looks like an issue with sloganizer.net")
|
2011-06-04 11:38:11 -04:00
|
|
|
phenny.say(slogan)
|
|
|
|
slogan.commands = ['slogan']
|
|
|
|
slogan.example = '.slogan Granola'
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-01-03 14:09:34 -05:00
|
|
|
print(__doc__.strip())
|