def listen_thread_work(self):
self.bot_handle=telepot.Bot(self.token)
last_check_status=False
bot_bind_ok=False
activation_fail_announce=False
while bot_bind_ok==False:
try:
self.name=self.bot_handle.getMe()[u"username"]
bot_bind_ok=True
except:
if activation_fail_announce==False:
report("l","Listener service activation error. Will keep trying...")
activation_fail_announce=True
time.sleep(LISTENER_SERVICE_THREAD_HEARTBEAT_SECONDS)
self.catch_up_IDs()
os.system("@title FileBot v"+__version__+" - "+self.name)
set_general_data("bot_name",self.name)
report("l","Listener service for bot \""+self.name+"\" is now active.")
self.is_active.set()
while self.keep_running.is_set()==True:
time.sleep(LISTENER_SERVICE_THREAD_HEARTBEAT_SECONDS)
response=[]
try:
response=self.bot_handle.getUpdates(offset=self.last_ID_checked+1)
check_status=True
except:
check_status=False
if check_status!=last_check_status:
last_check_status=check_status
if check_status==True:
set_general_data("online","yes")
report("l","Message retrieval is now online.")
else:
set_general_data("online","no")
report("l","Stopped being able to retrieve messages.")
self.organize_messages(response)
self.is_active.clear()
report("l","Listener has exited.")
self.has_exited.set()
return
评论列表
文章目录