def send_user(bot, update): session = DBSession() users = session.query(User).all() if not (Filters.text(update.message) | Filters.sticker(update.message) | Filters.photo(update.message) | Filters.video(update.message) | Filters.document(update.message)): bot.send_message(chat_id=update.message.id, text=NO_SUPPORT_FORMAT) return send_admin_msg(users=users, bot=bot, update=update) bot.send_message(chat_id=update.message.chat_id, text=USER_FORWARD_STOP) session.close() return ConversationHandler.END
def send_admin_msg(users, bot, update): if Filters.text(update.message): for user in users: bot.send_message(chat_id=user.id, text=update.message.text, parse_mode=ParseMode.HTML) sleep(1) elif Filters.sticker(update.message): for user in users: bot.send_sticker(chat_id=user.id, sticker=update.message.sticker.file_id) sleep(1) elif Filters.photo(update.message): for photo in update.message.photo: for user in users: bot.send_photo(chat_id=user.id, photo=photo.file_id, caption=update.message.caption) sleep(1) elif Filters.video(update.message): for user in users: bot.send_video(chat_id=user.id, video=update.message.video.file_id, caption=update.message.caption) sleep(1) elif Filters.audio(update.message): for user in users: bot.send_audio(chat_id=user.id, audio=update.message.audio.file_id, caption=update.message.caption) sleep(SEND_SLEEP) elif Filters.document(update.message): for user in users: bot.send_document(chat_id=user.id, document=update.message.document.file_id, caption=update.message.caption) sleep(1) else: return