def send_all(message): head = "!!! Рассылка для всех пользователей !!!\n" tail = "\n---------------------------------------" try: if base.get_user_step(message.chat.id) == "Send": file_info = bot.get_file(message.photo[-1].file_id) downloaded_file = bot.download_file(file_info.file_path) with open("temp.jpg", 'wb+') as new_file: new_file.write(downloaded_file) for id in base.get_all_ids(): bot.send_message(id, head) bot.send_photo(message.chat.id, photo=open("temp.jpg", 'rb')) bot.send_message(message.chat.id, "Ваша рассылка отправлена!", reply_markup=markups.admin()) except: for id in base.get_all_ids(): bot.send_message(id, head + message.text + tail) bot.send_message(message.chat.id, "Ваша рассылка отправлена!", reply_markup=markups.admin())
def start(message): sent = bot.send_message(message.chat.id, const.welcome_msg, reply_markup=markups.admin(message.chat.id)) bot.register_next_step_handler(sent, reply_msg)
def admin(message): if not base.is_admin(message.chat.id): bot.send_message(message.chat.id, "Нет прав доступа") else: bot.send_message(message.chat.id, "Админ-панель", reply_markup=markups.admin())
def admin(call): bot.edit_message_text("Админ-панель", chat_id=call.message.chat.id, message_id=call.message.message_id) bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=markups.admin())
def statistics(call): msg = "Всего продавцов: {clients}\nВсего покупателей: {users}".format(clients = base.count_clients(), users = base.count_users()) bot.edit_message_text(msg, chat_id=call.message.chat.id, message_id=call.message.message_id) bot.edit_message_reply_markup(chat_id=call.message.chat.id, message_id=call.message.message_id, reply_markup=markups.admin())