def callback(context, name, ob): obj = context.context if info.scope == 'class': callback = func.__get__(obj.get_plugin(ob), ob) else: callback = utils.wraps_with_context(func, obj) plugin = obj.get_plugin(utils.maybedotted(commands)) predicates.update(module=func.__module__) cmd_name = predicates.get('name', func.__name__) plugin[cmd_name] = (predicates, callback) obj.log.debug('Register command %r', cmd_name)
def callback(context, name, ob): obj = context.context if info.scope == 'class': self.callback = getattr(obj.get_plugin(ob), func.__name__) else: self.callback = wraps_with_context(func, obj) # a new instance is needed to keep this related to *one* bot # instance e = self.__class__(self.regexp, self.callback, venusian_category=self.venusian_category, iotype=self.iotype) obj.attach_events(e)
def callback(context, name, ob): obj = context.context if info.scope == 'class': callback = func.__get__(obj.get_plugin(ob), ob) else: callback = utils.wraps_with_context(func, obj) plugin = obj.get_plugin(utils.maybedotted(commands)) predicates.update(module=func.__module__) cmd_name = predicates.get('name', func.__name__) if not plugin.case_sensitive: cmd_name = cmd_name.lower() plugin[cmd_name] = (predicates, callback) obj.log.debug('Register command %r', cmd_name)
def callback(context, name, ob): obj = context.context if info.scope == 'class': callback = func.__get__(obj.get_plugin(ob), ob) else: callback = utils.wraps_with_context(func, obj) plugin = obj.get_plugin(utils.maybedotted(commands)) predicates.update(module=func.__module__) cmd_name = predicates.get('name', func.__name__) if not plugin.case_sensitive: cmd_name = cmd_name.lower() plugin[cmd_name] = (predicates, callback) aliases = predicates.get('aliases', None) if aliases is not None: for alias in aliases: plugin.aliases[alias] = cmd_name obj.log.debug('Register command %r %r', cmd_name, aliases) else: obj.log.debug('Register command %r', cmd_name)