disabled the SSL negation settings
This commit is contained in:
parent
c35debf2b4
commit
18282f59a6
29
streambot.py
29
streambot.py
@ -57,7 +57,7 @@ class MUCBot(slixmpp.ClientXMPP):
|
|||||||
# any presences you send yourself. To limit event handling
|
# any presences you send yourself. To limit event handling
|
||||||
# to a single room, use the events muc::room@server::presence,
|
# to a single room, use the events muc::room@server::presence,
|
||||||
# muc::room@server::got_online, or muc::room@server::got_offline.
|
# muc::room@server::got_online, or muc::room@server::got_offline.
|
||||||
self.add_event_handler("muc::{}::got_online".format(self.room), self.muc_online)
|
# self.add_event_handler("muc::{}::got_online".format(self.room), self.muc_online)
|
||||||
|
|
||||||
|
|
||||||
def start(self, event):
|
def start(self, event):
|
||||||
@ -121,7 +121,13 @@ class MUCBot(slixmpp.ClientXMPP):
|
|||||||
|
|
||||||
# publish images
|
# publish images
|
||||||
if len(msg['oob']['url']) > 0:
|
if len(msg['oob']['url']) > 0:
|
||||||
|
|
||||||
|
# reply from the bot
|
||||||
|
self.send_message(mto=msg['from'].bare,
|
||||||
|
mbody="I'll stream that image further, {}.".format(msg['mucnick']),
|
||||||
|
mtype='groupchat')
|
||||||
|
|
||||||
|
# save image to folder
|
||||||
url = msg['oob']['url']
|
url = msg['oob']['url']
|
||||||
filename = os.path.basename(url)
|
filename = os.path.basename(url)
|
||||||
targetDir = self.datadir
|
targetDir = self.datadir
|
||||||
@ -131,19 +137,14 @@ class MUCBot(slixmpp.ClientXMPP):
|
|||||||
|
|
||||||
targetFile = os.path.join(targetDir, filename)
|
targetFile = os.path.join(targetDir, filename)
|
||||||
|
|
||||||
# response = requests.get(url)
|
# needed to disable certificate validation, when we work in a local network:
|
||||||
# if response.status_code == 200:
|
# ctx = ssl.create_default_context()
|
||||||
# with open(targetFile, 'wb') as f:
|
# ctx.check_hostname = False
|
||||||
# f.write(response.content)
|
# ctx.verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
# needed to disable certificate validation:
|
|
||||||
ctx = ssl.create_default_context()
|
|
||||||
ctx.check_hostname = False
|
|
||||||
ctx.verify_mode = ssl.CERT_NONE
|
|
||||||
|
|
||||||
# save image to file
|
# write image to file
|
||||||
# urllib.request.urlretrieve(msg['oob']['url'], targetFile, context=ctx)
|
# u = urllib.request.urlopen(url, context=ctx) # use this line when SSL needs to be disabled
|
||||||
u = urllib.request.urlopen(url, context=ctx)
|
u = urllib.request.urlopen(url)
|
||||||
f = open(targetFile, 'wb')
|
f = open(targetFile, 'wb')
|
||||||
f.write(u.read())
|
f.write(u.read())
|
||||||
f.close()
|
f.close()
|
||||||
@ -160,6 +161,8 @@ class MUCBot(slixmpp.ClientXMPP):
|
|||||||
|
|
||||||
# publish regular messages (only when '#publish' is used in the message)
|
# publish regular messages (only when '#publish' is used in the message)
|
||||||
if '#stream' in msg['body']:
|
if '#stream' in msg['body']:
|
||||||
|
|
||||||
|
# reply from the bot
|
||||||
self.send_message(mto=msg['from'].bare,
|
self.send_message(mto=msg['from'].bare,
|
||||||
mbody="I'll stream that further, {}.".format(msg['mucnick']),
|
mbody="I'll stream that further, {}.".format(msg['mucnick']),
|
||||||
mtype='groupchat')
|
mtype='groupchat')
|
||||||
|
Loading…
Reference in New Issue
Block a user