def add_to_history(user_history, sender, receiver, amount, action, finish=False, tx_id="", tip_id=""):
# convert object to string of name if necessary
if type(user_history) is models.User:
user_history = user_history.username
if tip_id == "":
tip_id = random.randint(0, 99999999)
bot_logger.logger.info("Save for history user=%s, sender=%s, receiver=%s, amount=%s, action=%s, finish=%s" % (
user_history, sender, receiver, amount, action, finish))
db = TinyDB(config.history_path + user_history + '.json')
db.insert({
"id": tip_id,
"user": user_history,
"sender": sender,
"receiver": receiver,
"amount": amount,
"action": action,
"finish": finish,
"status": "",
"tx_id": tx_id,
'time': datetime.datetime.now().isoformat(),
})
db.close()
评论列表
文章目录