mirror of https://github.com/9001/r0c.git
parent
c190dfd3af
commit
b6494fbb13
|
@ -161,6 +161,7 @@ class Core(object):
|
|||
def push_worker(self, world, ifaces):
|
||||
self.pushthr_alive = True
|
||||
|
||||
nth_iter = 0
|
||||
last_ts = None
|
||||
last_date = None
|
||||
while not self.stopping:
|
||||
|
@ -190,6 +191,11 @@ class Core(object):
|
|||
if not client.handshake_sz:
|
||||
pass
|
||||
client.refresh(False)
|
||||
|
||||
nth_iter += 1
|
||||
if nth_iter % 600 == 0:
|
||||
for iface in ifaces:
|
||||
iface.save_configs()
|
||||
|
||||
self.pushthr_alive = False
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ class VT100_Server(asyncore.dispatcher):
|
|||
self.clients = []
|
||||
self.user_config = {}
|
||||
self.user_config_path = None
|
||||
self.user_config_changed = False
|
||||
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
if PY2:
|
||||
self.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
|
@ -93,6 +94,7 @@ class VT100_Server(asyncore.dispatcher):
|
|||
'inheritance bug: self.user_config_path not set')
|
||||
|
||||
self.user_config = {}
|
||||
self.user_config_changed = False
|
||||
if not os.path.isfile(self.user_config_path):
|
||||
print(' * {0} loaded 0 client configs'.format(self.__class__.__name__))
|
||||
return
|
||||
|
@ -113,6 +115,10 @@ class VT100_Server(asyncore.dispatcher):
|
|||
|
||||
def save_configs(self):
|
||||
with self.world.mutex:
|
||||
if not self.user_config_changed:
|
||||
return
|
||||
|
||||
self.user_config_changed = False
|
||||
with open(self.user_config_path, 'wb') as f:
|
||||
f.write('1\n'.encode('utf-8'))
|
||||
for k, v in sorted(self.user_config.items()):
|
||||
|
@ -279,7 +285,7 @@ class VT100_Client(asyncore.dispatcher):
|
|||
|
||||
def save_config(self):
|
||||
with self.world.mutex:
|
||||
self.host.user_config[self.addr[0]] = u' '.join([
|
||||
conf_str = u' '.join([
|
||||
|
||||
hex(int(time.time()*8.0))[2:].rstrip('L'),
|
||||
self.user.nick,
|
||||
|
@ -294,6 +300,15 @@ class VT100_Client(asyncore.dispatcher):
|
|||
# user config
|
||||
'1' if self.bell else '0'])
|
||||
|
||||
try:
|
||||
if self.host.user_config[self.addr[0]] == conf_str:
|
||||
return
|
||||
except:
|
||||
pass
|
||||
|
||||
self.host.user_config[self.addr[0]] = conf_str
|
||||
self.host.user_config_changed = True
|
||||
|
||||
|
||||
def set_codec(self, codec_name):
|
||||
multibyte = ['utf-8','shift_jis']
|
||||
|
|
|
@ -708,5 +708,6 @@ if you are using a mac, PgUp is fn-Shift-PgUp
|
|||
'(^|[^a-zA-Z0-9]){0}([^a-zA-Z0-9]|$)'.format(
|
||||
nick_re))
|
||||
|
||||
self.client.save_config()
|
||||
if self.active_chan:
|
||||
self.client.save_config()
|
||||
|
||||
|
|
Loading…
Reference in New Issue