/usr/share/pyshared/gplugs/urban.py is in gozerbot 0.99.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # plugs/urban.py
#
#
""" query urbandictionary """
__copyright__ = 'this file is in the public domain'
__author__ = "Bas van Oostveen"
from gozerbot.generic import geturl2
from gozerbot.commands import cmnds
from gozerbot.aliases import aliases
from gozerbot.examples import examples
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests
import urllib, json
plughelp.add('urban', 'query urbandictionary.com')
url = "http://www.urbandictionary.com/iphone/search/define?term="
def handle_urban(bot, ievent):
""" urban <what> .. search urban for <what> """
if len(ievent.args) > 0:
what = " ".join(ievent.args)
else:
ievent.missing('<search query>')
return
try:
data = geturl2(url + urllib.quote_plus(what))
if not data:
ievent.reply("word not found: %s" % what)
return
data = json.loads(data)
if data['result_type'] == 'no_results':
ievent.reply("word not found: %s" % what)
return
res = []
for r in data['list']:
res.append(r['definition'])
ievent.reply(res, dot=True) # dot=" | ")
except:
raise
cmnds.add('urban', handle_urban, 'USER')
examples.add('urban', 'urban <what> .. search \
urbandictionary for <what>','1) urban bot 2) urban shizzle')
|