Send a reply to the sender using Web API

            (This function supports formatted message
            when using a bot integration)

            If the message was send in a thread, answer in a thread per default.
175733
def reply_webapi(self, text, attachments=None, as_user=True, in_thread=None):
        
        if in_thread is None:
            in_thread = 'thread_ts' in self.body

        if in_thread:
            self.send_webapi(text, attachments=attachments, as_user=as_user, thread_ts=self.thread_ts)
        else:
            text = self.gen_reply(text)
            self.send_webapi(text, attachments=attachments, as_user=as_user)
967066
async def reply(self, *args, **kwargs):
        
        kwargs['reply_to'] = self.id
        return await self._client.send_message(
            await self.get_input_chat(), *args, **kwargs)
893935
@Override
  public void reply(WebSocket session,
                    HeadersAmp headers,
                    String to,
                    long qid,
                    Object value)
     throws IOException
  {
    /*
    try (OutputStream os = session.getBasicRemote().getSendStream()) {
      queryResult(os, headers, to, qid, value);
    }
    */
  }
116805
private void reply(final String response, final boolean failObtainResponse,
            final String errorMessage, final String stackTrace,
            final String statusCode, final int statusCodeInt) {

        /**
         * this is needed if NIO has not even send out! MEMROY LEAK if not.
         * double check
         */

        if (!isSentReply()) {
            //must update sentReply first to avoid duplicated msg.
            sentReply = true;
            final ResponseOnSingeRequest res = new ResponseOnSingeRequest(
                    response, failObtainResponse, errorMessage, stackTrace,
                    statusCode, statusCodeInt,
                    PcDateUtils.getNowDateTimeStrStandard(), null);

            if (!getContext().system().deadLetters().equals(sender)) {
                sender.tell(res, getSelf());
            }

            getLogger().debug(
                    "DEBUG: real response: " + response + " err: "
                            + errorMessage);
            if (getContext() != null) {
                getContext().stop(getSelf());
            }
        }
    }
315334
def ReceiveRaw(self, **kw):
        '''
        '''
        if self.data: return self.data
        trace = self.trace
        while 1:
            response = self.h.getresponse()
            self.reply_code, self.reply_msg, self.reply_headers, self.data = \
                response.status, response.reason, response.msg, response.read()
            if trace:
                print >>trace, "_" * 33, time.ctime(time.time()), "RESPONSE:"
                for i in (self.reply_code, self.reply_msg,):
                    print >>trace, str(i)
                print >>trace, "-------"
                print >>trace, str(self.reply_headers)
                print >>trace, self.data
            saved = None
            for d in response.msg.getallmatchingheaders('set-cookie'):
                if d[0] in [ ' ', '\t' ]:
                    saved += d.strip()
                else:
                    if saved: self.cookies.load(saved)
                    saved = d.strip()
            if saved: self.cookies.load(saved)
            if response.status == 401:
                if not callable(self.http_callbacks.get(response.status,None)):
                    raise RuntimeError, 'HTTP Digest Authorization Failed'
                self.http_callbacks[response.status](response)
                continue
            if response.status != 100: break

            # The httplib doesn't understand the HTTP continuation header.
            # Horrible internals hack to patch things up.
            self.h._HTTPConnection__state = httplib._CS_REQ_SENT
            self.h._HTTPConnection__response = None
        return self.data
610821
private void reply(final String response, final boolean error,
            final String errorMessage, final String stackTrace,
            final String statusCode, final int statusCodeInt,
            Map<String, List<String>> responseHeaders) {

        if (!sentReply) {
            // must update sentReply first to avoid duplicated msg.
            sentReply = true;

            final ResponseOnSingeRequest res = new ResponseOnSingeRequest(
                    response, error, errorMessage, stackTrace, statusCode,
                    statusCodeInt, PcDateUtils.getNowDateTimeStrStandard(),
                    responseHeaders);
            if (!getContext().system().deadLetters().equals(sender)) {
                sender.tell(res, getSelf());
            }
            if (getContext() != null) {
                getContext().stop(getSelf());
            }
        }

    }
90315
def SendReply(self,
                rdf_value=None,
                session_id=None,
                message_type=rdf_flows.GrrMessage.Type.MESSAGE):
    """"""
    # TODO(hanuszczak): This is pretty bad. Here we assume that if the session
    # id is not none we are "replying" to a well-known flow. If we are replying
    # to a well-known flow we cannot increment the response id (since these are
    # not really responses) because otherwise the parent flow will think it is
    # missing some responses.
    #
    # Moreover, the message queue (at least in the flow test helper workflow)
    # expects flow messages to have request id equal to 0. This is rather
    # convoluted and should be untangled in the future.
    #
    # Once we have a separate method for communicating with well-known flows
    # this if-statement should no longer be relevant (since setting custom
    # session ids would become illegal).
    if session_id is None:
      response_id = self.response_id
      request_id = self.message.request_id
      session_id = self.message.session_id
      self.response_id += 1
    else:
      response_id = 0
      request_id = 0

    self.grr_worker.SendReply(
        rdf_value,
        # This is not strictly necessary but adds context
        # to this response.
        name=self.__class__.__name__,
        session_id=session_id,
        response_id=response_id,
        request_id=request_id,
        message_type=message_type,
        task_id=self.message.Get("task_id") or None,
        require_fastpoll=self.require_fastpoll)
1231335
def __on_message(self, connection, sender, message):
        
        if message.strip() == '!bot send':
            cycle = itertools.cycle(string.digits)
            content = ''.join(next(cycle) for _ in range(100))
            self.send_message(sender, content)

        else:
            parts = message.split(':', 2)
            if not parts or parts[0] != 'HRLD':
                return

            if parts[1] == 'BEGIN':
                # Beginning of multi-line message
                self._queue[parts[2]] = []

            elif parts[1] == 'END':
                # End of multi-line message
                content = ''.join(self._queue.pop(parts[2]))
                self.__notify(sender, content)

            elif parts[1] == 'MSG':
                # Single-line message
                content = parts[2]
                self.__notify(sender, content)

            else:
                # Multi-line message continuation
                uid = parts[1]
                self._queue[uid].append(parts[2])
416498
def reply_to(self, value):
        
        if isinstance(value, str):
            value = ReplyTo(value, None)
        if isinstance(value, tuple):
            value = ReplyTo(value[0], value[1])
        self._reply_to = value
382344
def reply(self, text):
        
        # pylint: disable=W0212
        response = self.reddit_session._add_comment(self.fullname, text)
        # pylint: enable=W0212
        urls = [self.reddit_session.config['inbox']]
        if isinstance(self, Comment):
            urls.append(self.submission._api_link)  # pylint: disable=W0212
        elif isinstance(self, Message):
            urls.append(self.reddit_session.config['sent'])
        self.reddit_session.evict(urls)
        return response
945974
function(message) {
    // Send notification as a proactive message 
    var activity = message.activity
    var reference = TurnContext.getConversationReference(activity); 
    MicrosoftAppCredentials.trustServiceUrl(activity.serviceUrl);
    
    adapter.continueConversation(reference, async (context) => {
        // Complete the job.
        await bot.processChatResponse(context, message);
    });
}
236948
public void reply(HeadersAmp headers,
                    String to,
                    long qid,
                    Object value)
    throws IOException
  {
    if (log.isLoggable(Level.FINEST)) {
      log.finest(this + " reply " + value
                + "\n  {to:" + to + "," + headers + "}");
    }

    try {
      JsonWriterImpl jOut = _jOut;
      jOut.init();

      jOut.writeStartArray();
      jOut.write("reply");

      writeHeaders(jOut, headers);

      jOut.write(to);
      jOut.write(qid);

      jOut.write(value);

      jOut.writeEndArray();

      jOut.close();
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
      
      throw e;
    }
  }
1340497
static void sendResponse(String output, HttpServletResponse response)
      throws IOException {
    PrintWriter out = null;
    try {
      out = response.getWriter();
      out.write(output);
    } finally {
      if (out != null) {
        out.close();
      }
    }
  }
25641
def make_reply(self):
        
        return Message(
            to=str(self.sender),
            sender=str(self.to),
            body=self.body,
            thread=self.thread,
            metadata=self.metadata
        )
812261
def __reply(self, reply, args, kwargs):
        
        binding = self.method.binding.input
        msg = binding.get_message(self.method, args, kwargs)
        log.debug('inject (simulated) send message:\n%s', msg)
        binding = self.method.binding.output
        return self.succeeded(binding, reply)
1024853
def send_response(self, code, message=None):
        
        self.log_request(code)
        if message is None:
            if code in self.responses:
                message = self.responses[code][0]
            else:
                message = ''
        if self.request_version != 'HTTP/0.9':
            self.wfile.write("%s %d %s\r\n" %
                             (self.protocol_version, code, message))
            # print (self.protocol_version, code, message)
        self.send_header('Server', self.version_string())
        self.send_header('Date', self.date_time_string())
225126
private void reply(final String response, final boolean error,
            final String errorMessage, final String stackTrace,
            final String statusCode, final int statusCodeInt) {

        
        if (!sentReply) {
            
            //must update sentReply first to avoid duplicated msg.
            sentReply = true;
            // Close the connection. Make sure the close operation ends because
            // all I/O operations are asynchronous in Netty.
            if(channel!=null && channel.isOpen())
                channel.close().awaitUninterruptibly();
            final ResponseOnSingeRequest res = new ResponseOnSingeRequest(
                    response, error, errorMessage, stackTrace, statusCode,
                    statusCodeInt, PcDateUtils.getNowDateTimeStrStandard(), null);
            if (!getContext().system().deadLetters().equals(sender)) {
                sender.tell(res, getSelf());
            }
            if (getContext() != null) {
                getContext().stop(getSelf());
            }
        }

    }