Rename config section from 'thresholds' to 'presence'

このコミットが含まれているのは:
n9k 2022-06-16 23:43:28 +00:00
コミット 88d3785ec6
3個のファイルの変更14行の追加14行の削除

ファイルの表示

@ -33,7 +33,7 @@ def toml_to_flask_sections(config):
toml_to_flask_section_names,
toml_to_flask_section_memory,
toml_to_flask_section_tasks,
toml_to_flask_section_thresholds,
toml_to_flask_section_presence,
toml_to_flask_section_chat,
toml_to_flask_section_flood,
toml_to_flask_section_captcha,
@ -104,13 +104,13 @@ def toml_to_flask_section_tasks(config):
'TASK_BROADCAST_STREAM_INFO_UPDATE': cfg['broadcast_stream_info_update'],
}
def toml_to_flask_section_thresholds(config):
cfg = config['thresholds']
assert cfg['user_notwatching'] <= cfg['user_tentative'] <= cfg['user_absent']
def toml_to_flask_section_presence(config):
cfg = config['presence']
assert cfg['notwatching'] <= cfg['tentative'] <= cfg['absent']
return {
'THRESHOLD_USER_NOTWATCHING': cfg['user_notwatching'],
'THRESHOLD_USER_TENTATIVE': cfg['user_tentative'],
'THRESHOLD_USER_ABSENT': cfg['user_absent'],
'PRESENCE_NOTWATCHING': cfg['notwatching'],
'PRESENCE_TENTATIVE': cfg['tentative'],
'PRESENCE_ABSENT': cfg['absent'],
}
def toml_to_flask_section_chat(config):

ファイルの表示

@ -62,16 +62,16 @@ def get_default_name(user):
def get_presence(timestamp, user):
last_watching_ago = timestamp - user['last']['watching']
if last_watching_ago < CONFIG['THRESHOLD_USER_NOTWATCHING']:
if last_watching_ago < CONFIG['PRESENCE_NOTWATCHING']:
return Presence.WATCHING
last_seen_ago = timestamp - user['last']['seen']
if last_seen_ago < CONFIG['THRESHOLD_USER_TENTATIVE']:
if last_seen_ago < CONFIG['PRESENCE_TENTATIVE']:
return Presence.NOTWATCHING
if user['websockets']:
return Presence.NOTWATCHING
if last_seen_ago < CONFIG['THRESHOLD_USER_ABSENT']:
if last_seen_ago < CONFIG['PRESENCE_ABSENT']:
return Presence.TENTATIVE
return Presence.ABSENT

ファイルの表示

@ -72,10 +72,10 @@ cooldown = 12.0
expire_after = 5.0
overwrite = true
[thresholds]
user_notwatching = 8.0
user_tentative = 20.0
user_absent = 360.0
[presence]
notwatching = 8.0
tentative = 20.0
absent = 360.0
[nojs]
refresh_messages = 4.0