From eb0481815315733a82b636b84886df00050dbb3b Mon Sep 17 00:00:00 2001 From: SiHuan Date: Sat, 7 Mar 2020 17:11:08 +0800 Subject: [PATCH] ns up up up --- worker/ns.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/worker/ns.py b/worker/ns.py index 1aed0f6..99e2764 100644 --- a/worker/ns.py +++ b/worker/ns.py @@ -1,9 +1,15 @@ from zzcore import StdAns -from subprocess import run +from subprocess import check_output class Ans(StdAns): def GETMSG(self): + if len(self.parms) < 2: + return '不加参数是坏文明!' + domain = self.raw_msg['message'][4:] - r = run(["nslookup",domain],capture_output=True) - msg = bytes.decode(r.stdout) - return msg + try: + answer = check_output(['nslookup',domain],shell=False,timeout=4) + msg = bytes.decode(answer) + except: + msg = '汝干了什么! ns 超时了!' + return msg \ No newline at end of file