-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommandhelp.py
35 lines (30 loc) · 1.02 KB
/
commandhelp.py
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
"""
Command helper.
Copyright (c) 2013 learn_more
See the file license.txt or http://opensource.org/licenses/MIT for copying permission.
Lists all commands available to you (permission based).
"""
from commands import add, admin, commands as cmdlist, aliases as aliaslist
import fnmatch
def commands(connection, value = None):
names = []
for command in cmdlist:
command_func = cmdlist[command]
if (hasattr(command_func, 'user_types') and command not in connection.rights):
continue
include = False
if (value is None or fnmatch.fnmatch(command, value)):
include = True
aliases = []
for a in aliaslist:
if aliaslist[a] == command:
if (value is None or fnmatch.fnmatch(a, value)):
include = True
aliases.append(a)
cmd = command if len(aliases) == 0 else ('%s (%s)' % (command, ', '.join(aliases)))
if include:
names.append(cmd)
return 'Commands: %s' % (', '.join(names))
add(commands)
def apply_script(protocol, connection, config):
return protocol, connection