-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecks.py
48 lines (38 loc) · 1.02 KB
/
checks.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
36
37
38
39
40
41
42
43
44
45
46
47
48
import json
import asyncio
import contentTypes
from pydispatch import dispatcher
__version__ = "1.0.0"
__doc__ = """
Checks for the Facebook bot
"""
import inspect
def getSource(meth):
if inspect.ismethod(meth):
for cls in inspect.getmro(meth.__self__.__class__):
if cls.__dict__.get(meth.__name__) is meth:
return cls
meth = meth.__func__ # fallback to __qualname__ parsing
if inspect.isfunction(meth):
cls = getattr(
inspect.getmodule(meth),
meth.__qualname__.split(
'.<locals>',
1)[0].rsplit(
'.',
1)[0])
if isinstance(cls, type):
return cls
return None
commands = {}
def command(name=None):
def check(func):
setattr(func, 'is_command', True)
if name:
setattr(func, '__name__', name)
setattr(func, 'name', name)
func.is_command = True
return func
return check
def getCommands():
return commands