Exemplo n.º 1
0
    def send_chat_message(self,
                          peer_jid: str,
                          message: str,
                          bot_mention_jid=None):
        """
        Sends a text chat message to another person or a group with the given JID/username.

        :param peer_jid: The Jabber ID for which to send the message (looks like [email protected])
                         If you don't know the JID of someone, you can also specify a kik username here.
        :param message: The actual message body
        :param bot_mention_jid: If an official bot is referenced, their jid must be embedded as mention for them
        to respond.
        """
        peer_jid = self.get_jid(peer_jid)

        if self.is_group_jid(peer_jid):
            log.info("[+] Sending chat message '{}' to group '{}'...".format(
                message, peer_jid))
            return self._send_xmpp_element(
                chatting.OutgoingGroupChatMessage(peer_jid, message,
                                                  bot_mention_jid))
        else:
            log.info("[+] Sending chat message '{}' to user '{}'...".format(
                message, peer_jid))
            return self._send_xmpp_element(
                chatting.OutgoingChatMessage(peer_jid, message, False,
                                             bot_mention_jid))
Exemplo n.º 2
0
 def send_chat_message(self, peer_jid: str, message: str):
     """
     Sends a text chat message to another person or a group with the given JID/username.
     :param peer_jid: The Jabber ID for which to send the message (looks like [email protected])
                      If you don't know the JID of someone, you can also specify a kik username here.
     :param message: The actual message body
     """
     if self.is_group_jid(peer_jid):
         logging.info("[+] Sending chat message '{}' to group '{}'...".format(message, peer_jid))
         return self.send_xmpp_element(chatting.OutgoingGroupChatMessage(peer_jid, message))
     else:
         logging.info("[+] Sending chat message '{}' to user '{}'...".format(message, peer_jid))
         return self.send_xmpp_element(chatting.OutgoingChatMessage(peer_jid, message))