Networking module: improve curl stability
This commit is contained in:
parent
b0d0b4a234
commit
b9d7eda336
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
import http.client
|
import http.client
|
||||||
import json
|
import json
|
||||||
|
import socket
|
||||||
|
from urllib.parse import quote
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
@ -25,14 +27,17 @@ def help_full ():
|
|||||||
|
|
||||||
def cmd_curl(msg):
|
def cmd_curl(msg):
|
||||||
if len(msg.cmds) > 1:
|
if len(msg.cmds) > 1:
|
||||||
req = web.getURLContent(" ".join(msg.cmds[1:]))
|
try:
|
||||||
if req is not None:
|
req = web.getURLContent(" ".join(msg.cmds[1:]))
|
||||||
res = Response(msg.sender, channel=msg.channel)
|
if req is not None:
|
||||||
for m in req.decode().split("\n"):
|
res = Response(msg.sender, channel=msg.channel)
|
||||||
res.append_message(m)
|
for m in req.decode().split("\n"):
|
||||||
return res
|
res.append_message(m)
|
||||||
else:
|
return res
|
||||||
return Response(msg.sender, "Une erreur est survenue lors de l'accès à cette URL", channel=msg.channel)
|
else:
|
||||||
|
return Response(msg.sender, "Une erreur est survenue lors de l'accès à cette URL", channel=msg.channel)
|
||||||
|
except socket.error as e:
|
||||||
|
return Response(msg.sender, e.strerror, channel=msg.channel)
|
||||||
else:
|
else:
|
||||||
return Response(msg.sender, "Veuillez indiquer une URL à visiter.",
|
return Response(msg.sender, "Veuillez indiquer une URL à visiter.",
|
||||||
channel=msg.channel)
|
channel=msg.channel)
|
||||||
|
Loading…
Reference in New Issue
Block a user