Пример #1
0
def process_export(bot, update):
    query = update.callback_query
    bot.edit_message_text(
        text="{} {}".format(query.message.text, query.data), chat_id=query.message.chat_id,
        message_id=query.message.message_id)
    if query.data == 'png':
        quizes = quiz_storage.get_completed_quizes(query.message.chat_id)
        plot = get_quizes_plot(quizes)
        bot.send_photo(chat_id=query.message.chat_id, photo=plot)
    if query.data == 'csv':
        quizes = quiz_storage.get_completed_quizes(query.message.chat_id, limit=999)
        csv_buf = get_csv(quizes)
        bot.send_document(chat_id=query.message.chat_id, document=csv_buf, filename='m00d.csv')
Пример #2
0
def get_logs_handler(update, context):
    chat = utils.get_chat(context, update)
    chat_id = chat.effective_chat.id
    bot = utils.get_bot(context, update)
    logger.info(f'get_logs_handler -> {chat_id}')
    if utils.is_admin(chat_id):
        try:
            f = open('deliver_bot.log', 'rb')
            bot.send_document(
                chat_id=chat_id,
                document=f
            )
        except Exception as ex:
            logger.warning(f'{ex}')
Пример #3
0
def get_db_handler(update, context):
    chat = utils.get_chat(context, update)
    chat_id = chat.effective_chat.id
    bot = utils.get_bot(context, update)
    logger.info(f'get_db_handler -> {chat_id}')
    if utils.is_admin(chat_id):
        try:
            f_path = os.path.join(os.path.dirname(__file__), 'admin/db.sqlite')
            f = open(f_path, 'rb')
            bot.send_document(
                chat_id=chat_id,
                document=f
            )
        except Exception:
            pass
Пример #4
0
def get_report_handler(update, context):
    chat = utils.get_chat(context, update)
    chat_id = chat.effective_chat.id
    bot = utils.get_bot(context, update)
    logger.info(f'get_report_handler -> {chat_id}')

    db.export_orders_to_file()

    if utils.is_admin(chat_id):
        try:
            f = open('orders.csv', 'rb')
            bot.send_document(
                chat_id=chat_id,
                document=f
            )
        except Exception as ex:
            logger.warning(f'{ex}')
            pass