def create_poll(session, poll, user, chat, message=None): """Finish the poll creation.""" poll.created = True user.expected_input = None user.current_poll = None if message: message = message.edit_text( get_poll_text(session, poll), parse_mode='markdown', reply_markup=get_management_keyboard(poll), disable_web_page_preview=True, ) else: message = chat.send_message( get_poll_text(session, poll), parse_mode='markdown', reply_markup=get_management_keyboard(poll), disable_web_page_preview=True, ) reference = Reference(poll, admin_chat_id=chat.id, admin_message_id=message.message_id) session.add(reference) session.commit()
def send_styling_message(session, context): """Update the current styling menu message.""" context.query.message.edit_text( text=get_poll_text(session, context.poll), parse_mode='markdown', reply_markup=get_styling_settings_keyboard(context.poll), disable_web_page_preview=True, )
def show_styling_menu(session, context, poll): """Show the menu for sorting settings.""" context.query.message.edit_text( get_poll_text(session, context.poll), parse_mode='markdown', reply_markup=get_styling_settings_keyboard(poll), disable_web_page_preview=True, )
def create_poll(session, poll, user, chat, message=None): """Finish the poll creation.""" poll.created = True user.expected_input = None user.current_poll = None text = get_poll_text(session, poll) if len(text) > 4000: error_message = i18n.t('misc.over_4000', locale=user.locale) message = chat.send_message(error_message, parse_mode='markdown') session.delete(poll) return if message: message = message.edit_text( text, parse_mode='markdown', reply_markup=get_management_keyboard(poll), disable_web_page_preview=True, ) else: message = chat.send_message( text, parse_mode='markdown', reply_markup=get_management_keyboard(poll), disable_web_page_preview=True, ) if len(text) > 3000: error_message = i18n.t('misc.over_3000', locale=user.locale) message = chat.send_message(error_message, parse_mode='markdown') reference = Reference(poll, admin_chat_id=chat.id, admin_message_id=message.message_id) session.add(reference) session.commit() increase_stat(session, 'created_polls')