/usr/share/pyshared/gplugs/timer.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 | # plugs/timer.py
#
#
__copyright__ = 'this file is in the public domain'
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.plugins import plugins
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests
import time, copy
plughelp.add('timer', 'do a timing of a command')
def handle_timer(bot, ievent):
""" do a timing of a command """
if not ievent.rest:
ievent.reply('<cmnd>')
return
event = copy.deepcopy(ievent)
event.txt = ievent.rest
event.onlyqueues = True
starttime = time.time()
result = plugins.cmnd(bot, event, 60)
stoptime = time.time()
if not result:
ievent.reply('no result for %s' % ievent.rest)
return
result.insert(0, "%s seconds ==>" % str(stoptime-starttime))
ievent.reply('timer results: ', result)
cmnds.add('timer', handle_timer, ['USER', 'WEB'], allowqueue=False, \
threaded=True)
examples.add('timer', 'time a command', 'timer version')
tests.add('timer version')
|