Generates the simple message to send to the daemon for a keywords request.
978073
def keywords_message(query, index, return_hits)
      message = Message.new

      message.append_string query
      message.append_string index
      message.append_int return_hits ? 1 : 0

      message.to_s
    end
652623
def add_message(self, msg_content, folder, **kwargs):
        
        content = {'m': kwargs}
        content['m']['l'] = str(folder)
        content['m']['content'] = {'_content': msg_content}

        return self.request('AddMsg', content)
249908
def send(ch, message, **kwargs):
    
    params = {
        'type': kwargs.pop('req_type', 'self'),
        'key': settings.PUSHALL_API_KEYS[ch]['key'],
        'id': settings.PUSHALL_API_KEYS[ch]['id'],
        'title': kwargs.pop(
            "title", settings.PUSHALL_API_KEYS[ch].get('title') or ""),
        'text': message,
        'priority': kwargs.pop(
            "priority", settings.PUSHALL_API_KEYS[ch].get('priority') or "0"),
    }
    if kwargs:
        params.update(**kwargs)

    response = urlopen(
        Request('https://pushall.ru/api.php'),
        urlencode(params),
        timeout=10
    )

    if response.code != 200:
        raise PushAllError(response.read())

    json = loads(response.read())
    if json.get('error'):
        raise PushAllError(json.get('error'))

    return True
1331189
def send_message(client, message):
    """"""
    print(message)
    client.send("HTTP/1.1 200 OK\r\n\r\n{}".format(message).encode("utf-8"))
    client.close()
186184
def send_response_message(self, request_id, meta, body):
        
        self.response_messages.append((request_id, meta, body))
989246
def build_message(self):
        '''
        '''
        if self._text is None:
            raise InvalidPayloadError('text is required')

        message = {
            'text': self._text,
            'markdown': self._markdown
        }

        if self._channel != Incoming.DEFAULT_CHANNEL:
            message['channel'] = self._channel

        if self._attachments:
            message['attachments'] = []
            for attachment in self._attachments:
                if 'title' not in attachment and 'text' not in attachment:
                    raise InvalidPayloadError('title or text is required')
                message['attachments'].append(attachment)

        return message
840376
def message(self):
        ''' '''
        name = self.__class__.__name__
        return "{0} {1}".format(humanize(name),
                                pp(*self.expectedArgs, **self.expectedKwArgs))
824448
def generate_message(contract: Contract, condition_kwargs: Mapping[str, Any]) -> str:
    """"""
    # pylint: disable=protected-access
    parts = []  # type: List[str]

    if contract.location is not None:
        parts.append("{}:\n".format(contract.location))

    if contract.description is not None:
        parts.append("{}: ".format(contract.description))

    lambda_inspection = None  # type: Optional[ConditionLambdaInspection]
    if not _is_lambda(a_function=contract.condition):
        condition_text = contract.condition.__name__
    else:
        # We need to extract the source code corresponding to the decorator since inspect.getsource() is broken with
        # lambdas.

        # Find the line corresponding to the condition lambda
        lines, condition_lineno = inspect.findsource(contract.condition)
        filename = inspect.getsourcefile(contract.condition)

        decorator_inspection = inspect_decorator(lines=lines, lineno=condition_lineno, filename=filename)
        lambda_inspection = find_lambda_condition(decorator_inspection=decorator_inspection)

        assert lambda_inspection is not None, \
            "Expected lambda_inspection to be non-None if _is_lambda is True on: {}".format(contract.condition)

        condition_text = lambda_inspection.text

    parts.append(condition_text)

    repr_vals = repr_values(
        condition=contract.condition,
        lambda_inspection=lambda_inspection,
        condition_kwargs=condition_kwargs,
        a_repr=contract._a_repr)

    if len(repr_vals) == 0:
        # Do not append anything since no value could be represented as a string.
        # This could appear in case we have, for example, a generator expression as the return value of a lambda.
        pass

    elif len(repr_vals) == 1:
        parts.append(': ')
        parts.append(repr_vals[0])
    else:
        parts.append(':\n')
        parts.append('\n'.join(repr_vals))

    msg = "".join(parts)
    return msg
1281931
def msg(self, target, message, formatted=True, tags=None):
        """"""
        if formatted:
            message = unescape(message)

        self.send('PRIVMSG', params=[target, message], source=self.nick, tags=tags)
448870
def gotMessage(self, message_id, message):
        
        d = defer.maybeDeferred(self._handle_message, message)
        d.addCallback(self.generate_response)
        d.addCallback(lambda resp: self.reply(message_id, resp))
        return d
589582
def batch_message(cls, batch, request_ids):
        ''''''
        assert isinstance(batch, Batch)
        if not cls.allow_batches:
            raise ProtocolError.invalid_request(
                'protocol does not permit batches')
        id_iter = iter(request_ids)
        rm = cls.request_message
        nm = cls.notification_message
        parts = (rm(request, next(id_iter)) if isinstance(request, Request)
                 else nm(request) for request in batch)
        return cls.batch_message_from_parts(parts)
841016
def request_message(cls, item, request_id):
        ''''''
        assert isinstance(item, Request)
        return cls.encode_payload(cls.request_payload(item, request_id))
1004679
def _on_msg(self, msg):
        """"""
        data = msg['content']['data']

        # If the message is a call invoke, run the function and send
        # the results.
        if 'callback' in data:
            guid = data['callback']
            callback = callback_registry[guid]
            args = data['arguments']
            args = [self.deserialize(a) for a in args]
            index = data['index']

            results = callback(*args)
            return self.serialize(self._send('return', index=index, results=results))

        # The message is not a call invoke, it must be an object
        # that is a response to a Python request.
        else:
            index = data['index']
            immutable = data['immutable']
            value = data['value']
            if index in self._callbacks:
                self._callbacks[index].resolve({
                    'immutable': immutable,
                    'value': value
                })
                del self._callbacks[index]
967576
def cmd(send, msg, args):
    
    if not msg:
        msg = gen_word()
    send(gen_intensify(msg))
804
def write_command(self, request_id, msg):
        
        self.send_message(msg, 0)
        reply = self.receive_message(request_id)
        result = reply.command_response()

        # Raises NotMasterError or OperationFailure.
        helpers._check_command_response(result)
        return result
313263
def simple_response(self, status, msg=""):
    """"""
    status = str(status)
    buf = ["%s %s\r\n" % (self.environ['ACTUAL_SERVER_PROTOCOL'], status),
         "Content-Length: %s\r\n" % len(msg),
         "Content-Type: text/plain\r\n"]

    if status[:3] == "413" and self.response_protocol == 'HTTP/1.1':
      # Request Entity Too Large
      self.close_connection = True
      buf.append("Connection: close\r\n")

    buf.append("\r\n")
    if msg:
      buf.append(msg)
    return sockets.SendAll(self.conn, "".join(buf))
801062
def sendRequest(self, name, args):
        """"""
        (respEvt, id) = self.newResponseEvent()
        self.sendMessage({"id":id, "method":name, "params": args})
        return respEvt