|
@@ -831,43 +831,46 @@ class LocationBot(ircbot.SingleServerIRCBot):
|
|
ping_next = datetime.utcnow() + timedelta(minutes = 1)
|
|
ping_next = datetime.utcnow() + timedelta(minutes = 1)
|
|
|
|
|
|
while not self.__reloading:
|
|
while not self.__reloading:
|
|
- now = datetime.utcnow()
|
|
|
|
|
|
+ try:
|
|
|
|
+ now = datetime.utcnow()
|
|
|
|
|
|
- if now >= ping_next:
|
|
|
|
- self.connection.ping(self.connection.server)
|
|
|
|
|
|
+ if now >= ping_next:
|
|
|
|
+ self.connection.ping(self.connection.server)
|
|
|
|
|
|
- ping_next = now + timedelta(minutes = 1)
|
|
|
|
|
|
+ ping_next = now + timedelta(minutes = 1)
|
|
|
|
|
|
- if self.__locations_lock.acquire(False):
|
|
|
|
- if self.__locations and self.__channels.issubset(self.channels.keys()):
|
|
|
|
- for nick, channel, granularity, location, coordinates, accuracy, speed, heading, altitude, altitude_accuracy in self.__locations:
|
|
|
|
- aux = []
|
|
|
|
|
|
+ if self.__locations_lock.acquire(False):
|
|
|
|
+ if self.__locations and self.__channels.issubset(self.channels.keys()):
|
|
|
|
+ for nick, channel, granularity, location, coordinates, accuracy, speed, heading, altitude, altitude_accuracy in self.__locations:
|
|
|
|
+ aux = []
|
|
|
|
|
|
- if accuracy is not None:
|
|
|
|
- aux.append('accuracy: ' + self.__distance(accuracy))
|
|
|
|
|
|
+ if accuracy is not None:
|
|
|
|
+ aux.append('accuracy: ' + self.__distance(accuracy))
|
|
|
|
|
|
- if speed is not None:
|
|
|
|
- aux.append('speed: ' + self.__speed(speed))
|
|
|
|
|
|
+ if speed is not None:
|
|
|
|
+ aux.append('speed: ' + self.__speed(speed))
|
|
|
|
|
|
- if heading is not None:
|
|
|
|
- aux.append(u'heading: ' + self.__heading(heading))
|
|
|
|
|
|
+ if heading is not None:
|
|
|
|
+ aux.append(u'heading: ' + self.__heading(heading))
|
|
|
|
|
|
- if altitude is not None:
|
|
|
|
- aux.append('altitude: ' + self.__distance(altitude))
|
|
|
|
|
|
+ if altitude is not None:
|
|
|
|
+ aux.append('altitude: ' + self.__distance(altitude))
|
|
|
|
|
|
- if altitude_accuracy is not None:
|
|
|
|
- aux.append('altitude accuracy: ' + self.__distance(altitude_accuracy))
|
|
|
|
|
|
+ if altitude_accuracy is not None:
|
|
|
|
+ aux.append('altitude accuracy: ' + self.__distance(altitude_accuracy))
|
|
|
|
|
|
- if aux:
|
|
|
|
- aux = ' [%s]' % ', '.join(aux)
|
|
|
|
- else:
|
|
|
|
- aux = ''
|
|
|
|
|
|
+ if aux:
|
|
|
|
+ aux = ' [%s]' % ', '.join(aux)
|
|
|
|
+ else:
|
|
|
|
+ aux = ''
|
|
|
|
|
|
- self.connection.notice(channel, '%s is in %s%s %s' % (nick, location, aux, self.__url(nick, granularity, location, coordinates)))
|
|
|
|
|
|
+ self.connection.notice(channel, '%s is in %s%s %s' % (nick, location, aux, self.__url(nick, granularity, location, coordinates)))
|
|
|
|
|
|
- self.__locations = []
|
|
|
|
|
|
+ self.__locations = []
|
|
|
|
|
|
- self.__locations_lock.release()
|
|
|
|
|
|
+ self.__locations_lock.release()
|
|
|
|
+ except irclib.ServerNotConnectedError:
|
|
|
|
+ self.jump_server()
|
|
|
|
|
|
self.ircobj.process_once(0.2)
|
|
self.ircobj.process_once(0.2)
|
|
|
|
|