Skip to content

Commit

Permalink
防止机器人对聊
Browse files Browse the repository at this point in the history
  • Loading branch information
zeruniverse committed Jul 24, 2015
1 parent b1446f7 commit 6a27bef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions QQBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def __init__(self, vpath, qq=0):
logging.critical("登录失败,正在重试")

if ret['retcode'] != 0:
raise ValueError, "Login Retcode="+str(ret['retcode'])
return

VFWebQQ = ret['result']['vfwebqq']
Expand Down Expand Up @@ -421,6 +422,7 @@ def __init__(self, tuin, isSess, group_sig, service_type):
self.tqq = uin_to_account(tuin)
self.lastcheck = time.time()
self.lastseq=0
self.replystreak = 0
logging.info("私聊线程生成,私聊对象:"+str(self.tqq))
def check(self):
self.lastcheck = time.time()
Expand All @@ -439,8 +441,12 @@ def push(self, ipContent, seq):
return True
else:
self.lastseq=seq

#防止机器人对聊
if self.replystreak>30:
self.replystreak = 0
return True
try:
self.replystreak = self.replystreak + 1
logging.info("PM get info from AI: "+ipContent)
paraf={ 'userid' : str(self.tqq), 'key' : tulingkey, 'info' : ipContent}
info = HttpClient_Ist.Get('http://www.tuling123.com/openapi/api?'+urllib.urlencode(paraf))
Expand Down Expand Up @@ -685,8 +691,8 @@ def deleteall(self, content):
pass_time()
qqLogin = Login(vpath, qq)
except Exception, e:
logging.error(str(e))

logging.critical(str(e))
os._exit()
t_check = check_msg()
t_check.setDaemon(True)
t_check.start()
Expand Down

0 comments on commit 6a27bef

Please sign in to comment.