(func=None, command=None, thread=False)
this decorator is used to create a command the bot will respond to.
this decorator is used to create a command the bot will respond to.
this decorator is used to create a command the bot will respond to .
def cmd(func=None, command=None, thread=False):
    """
    this decorator is used to create a command the bot will respond to.
    """
    def decorator(func):
        func.__brutal_event = True
        func.__brutal_event_type = 'cmd'
        func.__brutal_trigger = None
        if command is not None and type(command) in (str, unicode):

            try:
                func.__brutal_trigger = re.compile(command)
            except Exception:
                logging.exception('failed to build regex for {0!r} from func {1!r}'.format(command, func.__name__))

        if func.__brutal_trigger is None:
            try:
                raw_name = r'^{0}$'.format(func.__name__)
                func.__brutal_trigger = re.compile(raw_name)
            except Exception:
                logging.exception('failing to build command from {0!r}'.format(func.__name__))
                func.__brutal_event = False

        if thread is True:
            func.__brutal_threaded = True

        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            return func(*args, **kwargs)
        return wrapper

    if func is None:
        return decorator
    else:
        return decorator(func)
def cmd ( func = None , command = None , thread = False ) : def decorator ( func ) : func . __brutal_event = True func . __brutal_event_type = 'cmd' func . __brutal_trigger = None if command is not None and type ( command ) in ( str , unicode ) : try : func . __brutal_trigger = re . compile ( command ) except Exception : logging . exception ( 'failed to build regex for {0!r} from func {1!r}' . format ( command , func . __name__ ) ) if func . __brutal_trigger is None : try : raw_name = r'^{0}$' . format ( func . __name__ ) func . __brutal_trigger = re . compile ( raw_name ) except Exception : logging . exception ( 'failing to build command from {0!r}' . format ( func . __name__ ) ) func . __brutal_event = False if thread is True : func . __brutal_threaded = True @ functools . wraps ( func ) def wrapper ( * args , * * kwargs ) : return func ( * args , * * kwargs ) return wrapper if func is None : return decorator else : return decorator ( func )