read web storage from config file
This commit is contained in:
parent
7f71b56988
commit
80059a7b91
14
session.py
14
session.py
|
@ -318,12 +318,16 @@ class Session(YowsupApp):
|
|||
image.caption = ''
|
||||
if image.isEncrypted():
|
||||
self.logger.debug('Received encrypted image message')
|
||||
ipath = "uploads/" + str(image.timestamp) + image.getExtension()
|
||||
self.logger.debug('Received encrypted image message22')
|
||||
if self.backend.specConf is not None and self.backend.specConf.__getitem__("service.web_directory") is not None and self.backend.specConf.__getitem__("service.web_url") is not None :
|
||||
ipath = "/" + str(image.timestamp) + image.getExtension()
|
||||
|
||||
with open(self.backend.specConf.__getitem__("service.web_directory") + ipath,"wb") as f:
|
||||
f.write(image.getMediaContent())
|
||||
url = self.backend.specConf.__getitem__("service.web_url") + ipath
|
||||
else:
|
||||
self.logger.warn('Received encrypted image: web storage not set in config!')
|
||||
url = image.url
|
||||
|
||||
with open("/srv/www/htdocs/" + ipath,"wb") as f:
|
||||
f.write(image.getMediaContent())
|
||||
url = "http://www/" + ipath
|
||||
else:
|
||||
url = image.url
|
||||
if participant is not None: # Group message
|
||||
|
|
|
@ -35,7 +35,7 @@ import threadutils
|
|||
sys.path.insert(0, os.getcwd())
|
||||
|
||||
from Spectrum2.iochannel import IOChannel
|
||||
|
||||
from config import SpectrumConfig
|
||||
from whatsappbackend import WhatsAppBackend
|
||||
from yowsup.common import YowConstants
|
||||
from yowsup.stacks import YowStack
|
||||
|
@ -64,6 +64,11 @@ logging.basicConfig(
|
|||
level = logging.DEBUG if args.debug else logging.INFO
|
||||
)
|
||||
|
||||
if args.config is not None:
|
||||
specConf = SpectrumConfig(args.config)
|
||||
else:
|
||||
specConf = None
|
||||
|
||||
# Handler
|
||||
def handleTransportData(data):
|
||||
try:
|
||||
|
@ -84,7 +89,7 @@ def connectionClosed():
|
|||
# Main
|
||||
io = IOChannel(args.host, args.port, handleTransportData, connectionClosed)
|
||||
|
||||
plugin = WhatsAppBackend(io, args.j)
|
||||
plugin = WhatsAppBackend(io, args.j, specConf)
|
||||
|
||||
plugin.handleBackendConfig({
|
||||
'features': [
|
||||
|
|
|
@ -30,10 +30,11 @@ from registersession import RegisterSession
|
|||
import logging
|
||||
|
||||
class WhatsAppBackend(SpectrumBackend):
|
||||
def __init__(self, io, spectrum_jid):
|
||||
def __init__(self, io, spectrum_jida, specConf):
|
||||
SpectrumBackend.__init__(self)
|
||||
self.logger = logging.getLogger(self.__class__.__name__)
|
||||
self.io = io
|
||||
self.specConf = specConf
|
||||
self.sessions = { }
|
||||
self.spectrum_jid = spectrum_jid
|
||||
# Used to prevent duplicate messages
|
||||
|
|
Loading…
Reference in a new issue