Send Text Message with mentions

@param peer     destination peer
@param text     message text
@param mentions user's mentions
10894
@ObjectiveCName("sendMessageWithPeer:withText:withMentions:")
    public void sendMessage(@NotNull Peer peer, @NotNull String text, @Nullable ArrayList<Integer> mentions) {
        sendMessage(peer, text, null, mentions, false);
    }
123486
async def send(self, clear=True, parse_mode=()):
        
        await self._client.send_message(
            self._peer, self.text, reply_to=self.reply_to_msg_id,
            link_preview=self.link_preview, parse_mode=parse_mode,
            clear_draft=clear
        )
1236599
@ObjectiveCName("forwardContentContentWithPeer:withContent:")
    public void forwardContent(Peer peer, AbsContent content) {
        modules.getMessagesModule().forwardContent(peer, content);
    }
246104
public final void sendMessageToAllNeighbors(Message m) {
		verifyEdgeUsage();
		outMsg.f1 = m;
		while (edges.hasNext()) {
			Tuple next = edges.next();
			outMsg.f0 = next.getField(1);
			out.collect(Either.Right(outMsg));
		}
	}
986620
protected void sendMessage(String dest, Message message) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Sends message {} to {}.",
                TextFormat.shortDebugString(message),
                dest);
    }
    this.transport.send(dest, message);
  }
852642
def send_group_text(self, sender, receiver, content):
        
        return self.send_text(sender, 'group', receiver, content)
840099
@Override
  public void handleMessage(PeerMessage msg) {
//    logger.trace("Received msg {} from {}", msg.getType(), this);
    if (isStopped.get())
      return;
    if (!torrent.isInitialized()) {
      torrent.initIfNecessary(this);
    }
    switch (msg.getType()) {
      case KEEP_ALIVE:
        // Nothing to do, we're keeping the connection open anyways.
        break;
      case CHOKE:
        this.choked = true;
        this.firePeerChoked();
        this.cancelPendingRequests();
        break;
      case UNCHOKE:
        this.choked = false;
        logger.trace("Peer {} is now accepting requests.", this);
        this.firePeerReady();
        break;
      case INTERESTED:
        this.interested = true;
        if (this.choking) {
          unchoke();
        }
        break;
      case NOT_INTERESTED:
        this.interested = false;
        if (!interesting) {
          unbind(true);
        }
        break;
      case HAVE:
        // Record this peer has the given piece
        PeerMessage.HaveMessage have = (PeerMessage.HaveMessage) msg;
        Piece havePiece = this.torrent.getPiece(have.getPieceIndex());

        synchronized (this.availablePiecesLock) {
          this.availablePieces.set(havePiece.getIndex());
          logger.trace("Peer {} now has {} [{}/{}].",
                  new Object[]{
                          this,
                          havePiece,
                          this.availablePieces.cardinality(),
                          this.torrent.getPieceCount()
                  });
        }

        this.firePieceAvailabity(havePiece);
        break;
      case BITFIELD:
        // Augment the hasPiece bit field from this BITFIELD message
        PeerMessage.BitfieldMessage bitfield =
                (PeerMessage.BitfieldMessage) msg;

        synchronized (this.availablePiecesLock) {
          this.availablePieces.or(bitfield.getBitfield());
          logger.trace("Recorded bitfield from {} with {} " +
                          "pieces(s) [{}/{}].",
                  new Object[]{
                          this,
                          bitfield.getBitfield().cardinality(),
                          this.availablePieces.cardinality(),
                          this.torrent.getPieceCount()
                  });
        }

        this.fireBitfieldAvailabity();
        break;
      case REQUEST:
        PeerMessage.RequestMessage request =
                (PeerMessage.RequestMessage) msg;
        logger.trace("Got request message for {} ({} {}@{}) from {}", new Object[]{
                Arrays.toString(TorrentUtils.getTorrentFileNames(torrent).toArray()),
                request.getPiece(),
                request.getLength(),
                request.getOffset(),
                this
        });
        Piece rp = this.torrent.getPiece(request.getPiece());

        // If we are choking from this peer and it still sends us
        // requests, it is a violation of the BitTorrent protocol.
        // Similarly, if the peer requests a piece we don't have, it
        // is a violation of the BitTorrent protocol. In these
        // situation, terminate the connection.
        if (!rp.isValid()) {
          logger.warn("Peer {} violated protocol, terminating exchange: " + this.isChoking() + " " + rp.isValid(), this);
          this.unbind(true);
          break;
        }

        if (request.getLength() >
                PeerMessage.RequestMessage.MAX_REQUEST_SIZE) {
          logger.warn("Peer {} requested a block too big, terminating exchange.", this);
          this.unbind(true);
          break;
        }

        // At this point we agree to send the requested piece block to
        // the remote peer, so let's queue a message with that block
        try {

          ByteBuffer bufferForMessage = PeerMessage.PieceMessage.createBufferWithHeaderForMessage(
                  request.getPiece(), request.getOffset(), request.getLength());

          rp.read(request.getOffset(), request.getLength(), bufferForMessage);

          this.send(PeerMessage.PieceMessage.craft(request.getPiece(),
                  request.getOffset(), bufferForMessage));
          this.upload.add(request.getLength());

          if (request.getOffset() + request.getLength() == rp.size()) {
            this.firePieceSent(rp);
          }
        } catch (IOException ioe) {
          logger.debug("error", ioe);
          this.fireIOException(new IOException(
                  "Error while sending piece block request!", ioe));
        }

        break;
      case PIECE:
        // Record the incoming piece block.

        // Should we keep track of the requested pieces and act when we
        // get a piece we didn't ask for, or should we just stay
        // greedy?
        PeerMessage.PieceMessage piece = (PeerMessage.PieceMessage) msg;
        Piece p = this.torrent.getPiece(piece.getPiece());

        logger.trace("Got piece ({} {}@{}) from {}", new Object[]{
                p.getIndex(),
                p.size(),
                piece.getOffset(),
                this
        });

        this.download.add(piece.getBlock().capacity());

        try {
          boolean isPieceDownloaded = false;
          synchronized (p) {
            // Remove the corresponding request from the request queue to
            //  make room for next block requests.
            this.removeBlockRequest(p);
            if (p.isValid()) {
              this.cancelPendingRequests(p);
              this.firePeerReady();
              logger.trace("Discarding block for already completed " + p);
              break;
            }
            //TODO add proper catch for IOException
            p.record(piece.getBlock(), piece.getOffset());

            // If the block offset equals the piece size and the block
            // length is 0, it means the piece has been entirely
            // downloaded. In this case, we have nothing to save, but
            // we should validate the piece.
            if (getRemainingRequestedPieces(p) == 0) {
              this.firePieceCompleted(p);
              isPieceDownloaded = true;
            }
          }
          if (isPieceDownloaded) {
            firePeerReady();
          }
        } catch (IOException ioe) {
          logger.error(ioe.getMessage(), ioe);
          this.fireIOException(new IOException(
                  "Error while storing received piece block!", ioe));
          break;
        }
        break;
      case CANCEL:
        // No need to support
        break;
    }
  }
604515
@ObjectiveCName("sendMessageWithMentionsDetect:withText:withMarkdownText:")
    public void sendMessageWithMentionsDetect(@NotNull Peer peer, @NotNull String text, @NotNull String markdownText) {
        sendMessage(peer, text, markdownText, null, true);
    }
478745
public void sendMessage(final SMSBroker sms) {
		
		final int smsId = sms.getId();
		final String smsRecipient = sms.getRecipient();
		final String smsMessage = sms.getMessage();
		
		if (logger.isDebugEnabled()) {
			logger.debug("Entering into send message with parameter : ");
			logger.debug("   - message id : " + smsId);
			logger.debug("   - message recipient : " + smsRecipient);
			logger.debug("   - message : " + smsMessage);
		}
		
		try {
			final String messageISOLatin = new String(smsMessage.getBytes(),"ISO-8859-1");
			if (logger.isDebugEnabled()) {
				logger.debug("sending encoded message : " + messageISOLatin);
			}

			final SMText smText = RequestFactory.createSMText(smsId, smsRecipient, messageISOLatin);
			smText.setNotificationLevel(NOTIFICATION_LEVEL);
			
			// only send the message if required
			if (!simulateMessageSending) {
				olmConnector.submit(smText);
                logger.debug("message with : " + " - id : " + smsId + "successfully sent");
			} else {
				logger.warn("Message with id : " + smsId + " not sent because simlation mode is enable");
			}

			
		} catch (Throwable t) {
			logger.error("An error occurs sending SMS : " + 
				     " - id : " + smsId + 
				     " - recipient : " + smsRecipient + 
				     " - message : " + smsMessage);
		}		

	}
483049
public void forwardBroadcast (Name from, byte levelOrMode, String bundle, String msg)
    {
        for (PeerNode peer : _peers.values()) {
            if (peer.nodeobj != null) {
                ((CrowdNodeObject)peer.nodeobj).crowdPeerService.deliverBroadcast(
                    from, levelOrMode, bundle, msg);
            }
        }
    }
274470
public void sendMessage(final SMSBroker sms) {
		
		final int smsId = sms.getId();
		final String smsRecipient = sms.getRecipient();
		final String smsMessage = sms.getMessage();
		
		logger.info("Send message to smsenvoi with parameter : ");
		logger.info("   - message id : " + smsId);
		logger.info("   - message recipient : " + smsRecipient);
		logger.info("   - message : " + smsMessage);
		
		try {
			
			// only send the message if required
			if (!simulateMessageSending) {
				save_message_id(sms, realSendMessage(sms));

				logger.info("message with : " + 
						  " - id : " + smsId + "successfully sent");
			} else {
				logger.warn("Message with id : " + smsId + " not sent because simlation mode is enable");
			}

			
		} catch (Throwable t) {
			logger.error("An error occurs sending SMS : " + 
				     " - id : " + smsId + 
				     " - recipient : " + smsRecipient + 
				     " - message : " + smsMessage, t);
		}		
	}
674506
public void send(final String aname, final String node,
            final OtpErlangObject msg) {
        try {
            final String currentNode = home.node();
            if (node.equals(currentNode)) {
                send(aname, msg);
            } else if (node.indexOf('@', 0) < 0
                    && node.equals(currentNode.substring(0,
                            currentNode.indexOf('@', 0)))) {
                send(aname, msg);
            } else {
                // other node
                final OtpCookedConnection conn = home.getConnection(node);
                if (conn == null) {
                    return;
                }
                conn.send(self, aname, msg);
            }
        } catch (final Exception e) {
        }
    }
985637
@ObjectiveCName("sendPhotoWithPeer:withName:withW:withH:withThumb:withDescriptor:")
    public void sendPhoto(@NotNull Peer peer, @NotNull String fileName,
                          int w, int h, @Nullable FastThumb fastThumb,
                          @NotNull String descriptor) {
        modules.getMessagesModule().sendPhoto(peer, fileName, w, h, fastThumb, descriptor);
    }
1224205
void broadcast(Iterator<String> peers, Message message) {
    transport.broadcast(peers, message);
  }
1164890
@Override
    public <T> void send(NotificationType type, List<T> messages) throws NotificationException {
        String[] strMessages = new String[messages.size()];
        for (int index = 0; index < messages.size(); index++) {
            strMessages[index] = getMessageJson(messages.get(index));
        }
        sendInternal(type, strMessages);
    }
1351379
@ObjectiveCName("sendMessageWithPeer:withText:withMarkdownText:")
    public void sendMessage(@NotNull Peer peer, @NotNull String text, @Nullable String markDownText) {
        sendMessage(peer, text, markDownText, null, false);
    }
149978
function(conversationId, name, text, callback) {
      send(null, conversationId, utils.messageText('name', name, text), callback);
    }