def set_fed_log(fed_id, chat_id): with FEDS_LOCK: global FEDERATION_BYOWNER, FEDERATION_BYFEDID, FEDERATION_BYNAME # Variables getfed = FEDERATION_BYFEDID.get(str(fed_id)) owner_id = getfed["owner"] fed_name = getfed["fname"] fed_members = getfed["fusers"] fed_rules = getfed["frules"] fed_log = str(chat_id) # Set user FEDERATION_BYOWNER[str(owner_id)]["flog"] = fed_log FEDERATION_BYFEDID[str(fed_id)]["flog"] = fed_log FEDERATION_BYNAME[fed_name]["flog"] = fed_log # Set on database fed = Federations(str(owner_id), fed_name, str(fed_id), fed_rules, fed_log, str(fed_members)) SESSION.merge(fed) SESSION.commit() print(fed_log) return True
def ensure_bot_in_db(): with INSERTION_LOCK: bot = Users(dispatcher.bot.id, dispatcher.bot.username) SESSION.merge(bot) SESSION.commit()