qcodes/utils/slack.py
def handle_messages(self, messages):
        """
        Performs commands depending on messages.
        This includes adding tasks to be performed during each update.
        """
        for user, user_messages in messages.items():
            for message in user_messages:
                if message.get('user', None) != self.users[user]['id']:
                    # Filter out bot messages
                    continue
                channel = self.users[user]['im_id']
                # Extract command (first word) and possible args
                command, args, kwargs = convert_command(message['text'])
                if command in self.commands:
                    msg = f'Executing {command}'
                    if args:
                        msg += f' {args}'
                    if kwargs:
                        msg += f' {kwargs}'
                    self.slack.chat_postMessage(text=msg, channel=channel)

                    func = self.commands[command]
                    try:
                        if isinstance(func, _BaseParameter):
                            results = func(*args, **kwargs)
                        else:
                            # Only add channel and Slack if they are explicit
                            # kwargs
                            func_sig = inspect.signature(func)
                            if 'channel' in func_sig.parameters:
                                kwargs['channel'] = channel
                            if 'slack' in func_sig.parameters:
                                kwargs['slack'] = self
                            results = func(*args, **kwargs)

                        if results is not None:
                            self.slack.chat_postMessage(
                                text=f'Results: {results}',
                                channel=channel)

                    except Exception:
                        self.slack.chat_postMessage(
                            text=f'Error: {traceback.format_exc()}',
                            channel=channel)
                else:
                    self.slack.chat_postMessage(
                        text='Command {} not understood. Try `help`'.format(
                            command),
                        channel=channel)

        Performs commands depending on messages.
        This includes adding tasks to be performed during each update.
        
Performs commands depending on messages.
This includes adding tasks to be performed during each update.
Performs commands depending on messages . This includes adding tasks to be performed during each update .
def handle_messages(self, messages):
        for user, user_messages in messages.items():
            for message in user_messages:
                if message.get('user', None) != self.users[user]['id']:
                    continue
                channel = self.users[user]['im_id']
                command, args, kwargs = convert_command(message['text'])
                if command in self.commands:
                    msg = f'Executing {command}'
                    if args:
                        msg += f' {args}'
                    if kwargs:
                        msg += f' {kwargs}'
                    self.slack.chat_postMessage(text=msg, channel=channel)
                    func = self.commands[command]
                    try:
                        if isinstance(func, _BaseParameter):
                            results = func(*args, **kwargs)
                        else:
                            func_sig = inspect.signature(func)
                            if 'channel' in func_sig.parameters:
                                kwargs['channel'] = channel
                            if 'slack' in func_sig.parameters:
                                kwargs['slack'] = self
                            results = func(*args, **kwargs)
                        if results is not None:
                            self.slack.chat_postMessage(
                                text=f'Results: {results}',
                                channel=channel)
                    except Exception:
                        self.slack.chat_postMessage(
                            text=f'Error: {traceback.format_exc()}',
                            channel=channel)
                else:
                    self.slack.chat_postMessage(
                        text='Command {} not understood. Try `help`'.format(
                            command),
                        channel=channel)
def handle_messages ( self , messages ) : for user , user_messages in messages . items ( ) : for message in user_messages : if message . get ( 'user' , None ) != self . users [ user ] [ 'id' ] : continue channel = self . users [ user ] [ 'im_id' ] command , args , kwargs = convert_command ( message [ 'text' ] ) if command in self . commands : msg = f'Executing {command}' if args : msg += f' {args}' if kwargs : msg += f' {kwargs}' self . slack . chat_postMessage ( text = msg , channel = channel ) func = self . commands [ command ] try : if isinstance ( func , _BaseParameter ) : results = func ( * args , ** kwargs ) else : func_sig = inspect . signature ( func ) if 'channel' in func_sig . parameters : kwargs [ 'channel' ] = channel if 'slack' in func_sig . parameters : kwargs [ 'slack' ] = self results = func ( * args , ** kwargs ) if results is not None : self . slack . chat_postMessage ( text = f'Results: {results}' , channel = channel ) except Exception : self . slack . chat_postMessage ( text = f'Error: {traceback.format_exc()}' , channel = channel ) else : self . slack . chat_postMessage ( text = 'Command {} not understood. Try `help`' . format ( command ) , channel = channel )
Performs commands depending on messages.
Performs commands depending on messages .
"""
        Performs commands depending on messages.
        This includes adding tasks to be performed during each update.
        """ # Filter out bot messages # Extract command (first word) and possible args # Only add channel and Slack if they are explicit # kwargs
self
messages