Pass session into SpectrumLayer so that session specific things can be called
This commit is contained in:
parent
ce1bf5d35b
commit
0c17a497ee
32
session.py
32
session.py
|
@ -98,7 +98,8 @@ class Session():
|
|||
backend = self.backend,
|
||||
user = self.user,
|
||||
db = self.db,
|
||||
legacyName = self.legacyName
|
||||
legacyName = self.legacyName,
|
||||
session = self
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -176,6 +177,20 @@ class Session():
|
|||
else:
|
||||
self.call("message_send", to=buddy + "@s.whatsapp.net", message=message)
|
||||
|
||||
def sendMessageToXMPP(self, buddy, messageContent, timestamp = ""):
|
||||
if timestamp:
|
||||
timestamp = time.strftime("%Y%m%dT%H%M%S", time.gmtime(timestamp))
|
||||
|
||||
if self.initialized == False:
|
||||
self.logger.debug("Message queued from %s to %s: %s",
|
||||
buddy, self.legacyName, messageContent)
|
||||
self.offlineQueue.append((buddy, messageContent, timestamp))
|
||||
else:
|
||||
self.logger.debug("Message sent from %s to %s: %s", buddy,
|
||||
self.legacyName, messageContent)
|
||||
self.backend.handleMessage(self.user, buddy, messageContent, "",
|
||||
"", timestamp)
|
||||
|
||||
def sendGroupMessageToXMPP(self, room, buddy, messageContent, timestamp = ""):
|
||||
if timestamp:
|
||||
timestamp = time.strftime("%Y%m%dT%H%M%S", time.gmtime(timestamp))
|
||||
|
@ -409,6 +424,7 @@ class SpectrumLayer(YowInterfaceLayer):
|
|||
self.user = layerEvent.getArg("user")
|
||||
self.legacyName = layerEvent.getArg("legacyName")
|
||||
self.db = layerEvent.getArg("db")
|
||||
self.session = layerEvent.getArg("session")
|
||||
|
||||
self.buddies = BuddyList(self.legacyName, self.db)
|
||||
self.bot = Bot(self)
|
||||
|
@ -490,17 +506,5 @@ class SpectrumLayer(YowInterfaceLayer):
|
|||
self.logger.info("Message received from %s to %s: %s (at ts=%s)",
|
||||
buddy, self.legacyName, messageContent, timestamp)
|
||||
|
||||
self.sendMessageToXMPP(buddy, messageContent, timestamp)
|
||||
self.session.sendMessageToXMPP(buddy, messageContent, timestamp)
|
||||
# if receiptRequested: self.call("message_ack", (jid, messageId))
|
||||
|
||||
def sendMessageToXMPP(self, buddy, messageContent, timestamp = ""):
|
||||
if timestamp:
|
||||
timestamp = time.strftime("%Y%m%dT%H%M%S", time.gmtime(timestamp))
|
||||
|
||||
if self.initialized == False:
|
||||
self.logger.debug("Message queued from %s to %s: %s", buddy, self.legacyName, messageContent)
|
||||
self.offlineQueue.append((buddy, messageContent, timestamp))
|
||||
else:
|
||||
self.logger.debug("Message sent from %s to %s: %s", buddy, self.legacyName, messageContent)
|
||||
self.backend.handleMessage(self.user, buddy, messageContent, "", "", timestamp)
|
||||
|
||||
|
|
Loading…
Reference in a new issue