forked from wiai/doorbot
load text from config
parent
e91d2948d1
commit
df11aef895
9
bot.py
9
bot.py
|
|
@ -19,7 +19,8 @@ def get_status():
|
|||
status["timestamp"] = parse_time(status['timestamp'])
|
||||
return status
|
||||
|
||||
def get_status_text(src=get_status):
|
||||
def get_status_text(config, src=get_status):
|
||||
return config["texts"][str(get_status()["doorstate"])]
|
||||
if get_status()["doorstate"]:
|
||||
text = "fs WIAI is open :)"
|
||||
else:
|
||||
|
|
@ -35,9 +36,9 @@ def post(chats, text, token):
|
|||
def main(args={"config": "settings.json"}):
|
||||
log.info("run once")
|
||||
config = json.load(open(args['config']))
|
||||
text = get_status_text()
|
||||
text = get_status_text(config)
|
||||
post(config['groups'], text, config['token'])
|
||||
post_plot(config)
|
||||
#post_plot(config)
|
||||
|
||||
def loop(args={"config": "settings.json"}):
|
||||
log.info("prepare loop")
|
||||
|
|
@ -62,7 +63,7 @@ def do_loop(config):
|
|||
changed = True
|
||||
if changed:
|
||||
last_state = new_state
|
||||
text = get_status_text(lambda: last_state)
|
||||
text = get_status_text(config, lambda: last_state)
|
||||
post(config["groups"], text, config["token"])
|
||||
log.info("run pending tasks")
|
||||
schedule.run_pending()
|
||||
|
|
|
|||
|
|
@ -9,5 +9,10 @@
|
|||
"WIAIdoorTest": -234502,
|
||||
"name": -1333,
|
||||
"fswiai main": -1001
|
||||
},
|
||||
"texts":{
|
||||
"-1": "fs WIAI is undefined ¯\_(ツ)_/¯",
|
||||
"0": "fs WIAI is closed :(",
|
||||
"1": "fs WIAI is open :)"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue