Parse server urls using parse_qs
This commit is contained in:
parent
26d1f5b6e8
commit
2e5834a89d
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
def factory(uri, ssl=False, **init_args):
|
def factory(uri, ssl=False, **init_args):
|
||||||
from urllib.parse import urlparse, unquote
|
from urllib.parse import urlparse, unquote, parse_qs
|
||||||
o = urlparse(uri)
|
o = urlparse(uri)
|
||||||
|
|
||||||
srv = None
|
srv = None
|
||||||
@ -44,25 +44,26 @@ def factory(uri, ssl=False, **init_args):
|
|||||||
modifiers = o.path.split(",")
|
modifiers = o.path.split(",")
|
||||||
target = unquote(modifiers.pop(0)[1:])
|
target = unquote(modifiers.pop(0)[1:])
|
||||||
|
|
||||||
queries = o.query.split("&")
|
# Read query string
|
||||||
for q in queries:
|
params = parse_qs(o.query)
|
||||||
if "=" in q:
|
|
||||||
key, val = tuple(q.split("=", 1))
|
if "msg" in params:
|
||||||
else:
|
|
||||||
key, val = q, ""
|
|
||||||
if key == "msg":
|
|
||||||
if "on_connect" not in args:
|
if "on_connect" not in args:
|
||||||
args["on_connect"] = []
|
args["on_connect"] = []
|
||||||
args["on_connect"].append("PRIVMSG %s :%s" % (target, unquote(val)))
|
args["on_connect"].append("PRIVMSG %s :%s" % (target, params["msg"]))
|
||||||
elif key == "key":
|
|
||||||
|
if "key" in params:
|
||||||
if "channels" not in args:
|
if "channels" not in args:
|
||||||
args["channels"] = []
|
args["channels"] = []
|
||||||
args["channels"].append((target, unquote(val)))
|
args["channels"].append((target, params["key"]))
|
||||||
elif key == "pass":
|
|
||||||
args["password"] = unquote(val)
|
|
||||||
elif key == "charset":
|
|
||||||
args["encoding"] = unquote(val)
|
|
||||||
|
|
||||||
|
if "pass" in params:
|
||||||
|
args["password"] = params["pass"]
|
||||||
|
|
||||||
|
if "charset" in params:
|
||||||
|
args["encoding"] = params["charset"]
|
||||||
|
|
||||||
|
#
|
||||||
if "channels" not in args and "isnick" not in modifiers:
|
if "channels" not in args and "isnick" not in modifiers:
|
||||||
args["channels"] = [ target ]
|
args["channels"] = [ target ]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user