auto reconnect for handling connection problems cf #3202
This commit is contained in:
parent
e5d1d76a7d
commit
5f0d1c435b
3
bot.py
3
bot.py
@ -256,10 +256,13 @@ def main():
|
|||||||
ready_to_read, b, c = select.select([ircsock],[],[], 1) # b&c are ignored here
|
ready_to_read, b, c = select.select([ircsock],[],[], 1) # b&c are ignored here
|
||||||
process_newcomers(WelcomeBot, [i for i in WelcomeBot.newcomers if i.around_for() > WelcomeBot.wait_time], ircsock,settings.channel, settings.channel_greeters)
|
process_newcomers(WelcomeBot, [i for i in WelcomeBot.newcomers if i.around_for() > WelcomeBot.wait_time], ircsock,settings.channel, settings.channel_greeters)
|
||||||
if ready_to_read:
|
if ready_to_read:
|
||||||
|
last_read = datetime.datetime.utcnow()
|
||||||
ircmsg = msg_handler(ircsock) # gets message from ircsock
|
ircmsg = msg_handler(ircsock) # gets message from ircsock
|
||||||
ircmsg, actor = parse_messages(ircmsg) # parses it or returns None
|
ircmsg, actor = parse_messages(ircmsg) # parses it or returns None
|
||||||
if ircmsg is not None: # If we were able to parse it
|
if ircmsg is not None: # If we were able to parse it
|
||||||
message_response(WelcomeBot, ircmsg, actor, ircsock, settings.channel, settings.channel_greeters) # Respond to the parsed message
|
message_response(WelcomeBot, ircmsg, actor, ircsock, settings.channel, settings.channel_greeters) # Respond to the parsed message
|
||||||
|
if datetime.datetime.utcnow() - last_read > datetime.timedelta(minutes=10):
|
||||||
|
raise Exception('timeout: nothing to read on socket since 10 minutes')
|
||||||
|
|
||||||
if __name__ == "__main__": # This line tells the interpreter to only execute main() if the program is being run, not imported.
|
if __name__ == "__main__": # This line tells the interpreter to only execute main() if the program is being run, not imported.
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
Loading…
Reference in New Issue
Block a user