cosmicbot/utils.py

10 lines
383 B
Python
Raw Normal View History

import plugin, subprocess
def register_command_call(command,cli,use_args=False,verify_args=lambda args: args):
@plugin.command(command)
def on_call(self,channel,nick,*args):
output = subprocess.check_output([cli]+list(verify_args(args) if use_args else [])).decode("ascii").split("\n")
output = filter(None,output)
for line in output:
self.say(channel,"{}".format(line))