Browse Source

Send xhtml on group message to XMPP MUC

pull/56/head
moyamo 7 years ago
parent
commit
e32365a065
  1. 12
      session.py
  2. 4
      whatsappbackend.py

12
session.py

@ -279,7 +279,7 @@ class Session(YowsupApp):
if participant is not None: # Group message
partname = participant.split('@')[0]
if notify is None:
notify = "";
notify = ""
self.sendGroupMessageToXMPP(buddy, partname, messageContent,
timestamp, notify)
else:
@ -479,9 +479,9 @@ class Session(YowsupApp):
self.logger.info("Stopped typing: %s to %s", self.legacyName, buddy)
self.sendTyping(buddy, False)
def sendMessageToWA(self, sender, message, ID):
self.logger.info("Message sent from %s to %s: %s",
self.legacyName, sender, message)
def sendMessageToWA(self, sender, message, ID, xhtml=""):
self.logger.info("Message sent from %s to %s: %s (xhtml=%s)",
self.legacyName, sender, message, xhtml)
message = message.encode("utf-8")
# FIXME: Fragile, should pass this in to onDlerror
@ -519,11 +519,11 @@ class Session(YowsupApp):
self.logger.debug("Group Message from %s to %s Groups: %s",
group.nick , group , self.groups)
self.backend.handleMessage(
self.user, room, message.decode('utf-8'), group.nick
self.user, room, message.decode('utf-8'), group.nick, xhtml=xhtml
)
except KeyError:
self.logger.error('Group not found: %s', room)
if (".jpg" in message.lower()) or (".webp" in message.lower()):
if (".jpg" in message.lower()):
self.imgType = "jpg"

4
whatsappbackend.py

@ -61,9 +61,9 @@ class WhatsAppBackend(SpectrumBackend):
# causes duplicate messages. Thus we should not send consecutive
# messages with the same id
if ID == '':
self.sessions[user].sendMessageToWA(buddy, message, ID)
self.sessions[user].sendMessageToWA(buddy, message, ID, xhtml)
elif user not in self.lastMsgId or self.lastMsgId[user] != ID:
self.sessions[user].sendMessageToWA(buddy, message, ID)
self.sessions[user].sendMessageToWA(buddy, message, ID, xhtml)
self.lastMsgId[user] = ID
def handleJoinRoomRequest(self, user, room, nickname, pasword):

Loading…
Cancel
Save