Make bot empty the queue on every ping
This commit is contained in:
parent
a0b1f7f4c5
commit
6acd507b2b
16
client.py
16
client.py
|
@ -35,6 +35,8 @@ with open('config.json') as f:
|
|||
jld = f.read()
|
||||
config = json.loads(jld)
|
||||
|
||||
NODEAMON = config['nodaemon']
|
||||
|
||||
|
||||
uds_addr = config['uds']
|
||||
try:
|
||||
|
@ -58,7 +60,7 @@ def uds_thread(in_q):
|
|||
connection.sendall(bytes("ACK" + LINEEND, 'UTF-8'))
|
||||
in_q.put_nowait(data)
|
||||
else:
|
||||
connection.sendall(bytes("NACK" + LINEEND))
|
||||
connection.sendall(bytes("NACK" + LINEEND, 'UTF-8'))
|
||||
continue
|
||||
except Exception as e:
|
||||
logging.exception(str(e))
|
||||
|
@ -127,12 +129,12 @@ def do_main_loop():
|
|||
r = generate_response(text[0],text[2][1])
|
||||
if r is not None:
|
||||
irc.send_privmsg(config['channel'],r)
|
||||
try:
|
||||
d = q.get_nowait()
|
||||
irc.send_privmsg(config['channel'], d.decode("UTF-8"))
|
||||
except Empty:
|
||||
printred("Empty")
|
||||
|
||||
|
||||
if text[1] == "PING":
|
||||
while not q.empty():
|
||||
d = q.get_nowait()
|
||||
irc.send_privmsg(config['channel'], d.decode("UTF-8"))
|
||||
|
||||
|
||||
|
||||
except IRCError as e:
|
||||
|
|
Loading…
Reference in New Issue