/usr/share/pyshared/gplugs/search.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 | # plugs/search.py
#
#
from gozerbot.generic import handle_exception
from gozerbot.commands import cmnds
from gozerbot.plugins import plugins
from gozerbot.threads.thr import start_new_thread
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.tests import tests
import Queue
plughelp.add('search', 'search all plugins that provide a search() function')
def handle_search(bot, ievent):
""" search all plugins that provide a search() function """
result = {}
queue = Queue.Queue()
try:
what = ievent.args[0]
except IndexError:
ievent.missing('<what>')
return
threads = []
plugs = dict(plugins.plugs)
for name, plug in plugs.iteritems():
try:
searchfunc = getattr(plug, 'search')
if searchfunc:
threadid = start_new_thread(searchfunc, (what, queue))
threads.append(threadid)
except AttributeError:
pass
except Exception, ex:
handle_exception()
for i in threads:
i.join()
queue.put(None)
result = []
while 1:
res = queue.get_nowait()
if not res:
break
result.append(res)
ievent.reply('search results for %s => ' % what, result, dot=True)
cmnds.add('search', handle_search, ['USER', 'CLOUD', 'WEB'])
examples.add('search', 'search all bot data for <item>', 'search gozer')
tests.add('search', 'search gozerbot')
|