~ubuntu-branches/ubuntu/precise/gozerbot/precise

« back to all changes in this revision

Viewing changes to build/lib/gozerplugs/plugs/code.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Malcolm
  • Date: 2008-06-02 19:26:39 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080602192639-3rn65nx4q1sgd6sy
Tags: 0.8.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# plugs/code.py
2
 
#
3
 
#
4
 
 
5
 
""" code related commands """
6
 
 
7
 
__copyright__ = 'this file is in the public domain'
8
 
 
9
 
from gozerbot.redispatcher import rebefore, reafter
10
 
from gozerbot.commands import cmnds
11
 
from gozerbot.examples import examples
12
 
from gozerbot.generic import exceptionlist
13
 
from gozerbot.plugins import plugins
14
 
from gozerbot.aliases import aliasset
15
 
from gozerbot.plughelp import plughelp
16
 
 
17
 
plughelp.add('code', 'the code plugin provides code related commands')
18
 
 
19
 
def handle_showexceptions(bot, ievent):
20
 
    """ show exception list """
21
 
    ievent.reply(str(exceptionlist))
22
 
 
23
 
cmnds.add('code-exceptions' , handle_showexceptions, 'OPER')
24
 
examples.add('code-exceptions', 'show exception list', 'code-exceptions')
25
 
aliasset('exceptions', 'code-exceptions')
26
 
 
27
 
def handle_funcnames(bot, ievent):
28
 
    """ show function names of a plugin """
29
 
    try:
30
 
        plugname = ievent.args[0]
31
 
    except IndexError:
32
 
        ievent.missing('<plugname>')
33
 
        return
34
 
    if not plugins.exist(plugname):
35
 
        ievent.reply('no %s plugin exists' % plugname)
36
 
        return
37
 
    funcnames = []
38
 
    funcnames = rebefore.getfuncnames(plugname)
39
 
    funcnames += cmnds.getfuncnames(plugname)
40
 
    funcnames += reafter.getfuncnames(plugname)
41
 
    if funcnames:
42
 
        ievent.reply(funcnames, dot=True)
43
 
    else:
44
 
        ievent.reply("can't find funcnames for %s plugin" % plugname)
45
 
        
46
 
cmnds.add('code-funcnames', handle_funcnames, 'OPER')
47
 
examples.add('code-funcnames', 'show function names of a plugin', \
48
 
'code-funcnames birthday')
49
 
aliasset('funcnames', 'code-funcnames')