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,6 +27,7 @@ def help_full ():
|
|||||||
|
|
||||||
def cmd_curl(msg):
|
def cmd_curl(msg):
|
||||||
if len(msg.cmds) > 1:
|
if len(msg.cmds) > 1:
|
||||||
|
try:
|
||||||
req = web.getURLContent(" ".join(msg.cmds[1:]))
|
req = web.getURLContent(" ".join(msg.cmds[1:]))
|
||||||
if req is not None:
|
if req is not None:
|
||||||
res = Response(msg.sender, channel=msg.channel)
|
res = Response(msg.sender, channel=msg.channel)
|
||||||
@ -33,6 +36,8 @@ def cmd_curl(msg):
|
|||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
return Response(msg.sender, "Une erreur est survenue lors de l'accès à cette URL", channel=msg.channel)
|
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