Created
March 20, 2020 16:40
-
-
Save danbst/86c68616e37df60b6439db7cb5d2e629 to your computer and use it in GitHub Desktop.
str gen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_users_str(db, config, with_orders=False, with_ids=False): | |
all_s = [] | |
total_orders = 0 | |
if with_orders: | |
for user in db: | |
id_prefix = f"{user['telegram_id']} - " if with_ids else "" | |
is_ordered = user.get('order_food', config['DEFAULT_ORDER']) | |
if is_ordered: | |
total_orders += 1 | |
all_s.append(f"{id_prefix}{user['name']} - {is_ordered}") | |
all_s.append("\n") | |
all_s.append(f"{config['BOT']['TOTAL_USERS']}{len(db)}) | |
all_s.append(f"{config['BOT']['TOTAL_ORDERS']}{total_orders}) | |
return "\n".join(all_s) | |
else: | |
for user in db: | |
id_prefix = f"{user['telegram_id']} - " if with_ids else "" | |
all_s.append(f"{id_prefix}{user['name']}") | |
all_s.append("\n") | |
all_s.append(f"{config['BOT']['TOTAL_USERS']}{len(db)}) | |
return "\n".join(all_s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment