def active_user_address(cls, username, address):
# sanitize (just lower)
username = str(unicode(username).lower())
if UserStorage.exist(username):
db = TinyDB(config.user_file)
table = db.table(username)
# check if address not already exist
user_db = Query()
data = table.count(user_db.address == address)
if data == 1:
# disable all other address
enabled_address = table.search(user_db.enable == True)
for item in enabled_address:
table.update({"enable": False}, eids=[item.eid])
# enable only one
table.update({"enable": True}, user_db.address == address)
else:
bot_logger.logger.error("active a not found address (%s) of user %s " % (str(address), str(username)))
else:
bot_logger.logger.error("active address of un-registered user %s " % (str(username)))
评论列表
文章目录