pinhook/pinhook/plugin.py

34 lines
572 B
Python
Raw Normal View History

2017-09-27 21:55:00 +00:00
cmds = []
class Output:
def __init__(self, msg_type, msg):
self.msg_type = msg_type
self.msg = self.sanitize(msg)
def sanitize(self, msg):
return msg.splitlines()
2017-09-27 21:55:00 +00:00
def action(msg):
return Output('action', msg)
def message(msg):
return Output('message', msg)
def add_plugin(command, func):
cmds.append({'cmd': command, 'func': func})
def clear_plugins():
cmds.clear()
def register(command):
def register_for_command(func):
add_plugin(command, func)
return func
return register_for_command