json_response['id'], json_response['cpf'], json_response['nomeConsumidor'], json_response['codigoCredor'], json_response['nomeCredor'], json_response['valorTotal'], json_response['dataCalculo']) for divida in json_response['carteiras']: resultados += dialogs['divida'].format( divida['id'], divida['nome'], divida['numero'], divida['valorSaldoDevedor'], divida['valorJuros'], divida['valorMulta'], divida['valorDesconto'], divida['valorTotal']) for fatura in divida['contratos']: resultados += dialogs['fatura'].format( fatura['numero'], fatura['valorSaldoDevedor'], fatura['valorJuros'], fatura['valorMulta'], fatura['valorDesconto'], fatura['valorTotal'], fatura['diasAtraso'], fatura['descricaoDetalheContrato'], fatura['cedente'], fatura['cedente']) except KeyError: file = bytes(json.dumps(json_response, indent=4), 'utf-8') bot.send_document(message.chat.id, file) else: bot.reply_to(message, resultados, parse_mode='markdown') file = bytes(json.dumps(json_response, indent=4), 'utf-8') bot.send_document(message.chat.id, file) bot.polling(none_stop=True)
from add_handlers import add_confirmation_handler, add_location_handler,\ add_place_handler, add_start_handler from list_handlers import request_list_handler from reser_handlers import reset_handler from start_handlers import start_handler from settings import bot if __name__ == '__main__': bot.polling()
obj = ChatLink.get(chat_id=message.chat.id) except ChatLink.DoesNotExist: pass else: link = obj.link obj.delete_instance() bot.reply_to(message, f'Ссылка "{link}" удалена') @bot.message_handler(commands=['link']) def curr_link(message): link = '' try: obj = ChatLink.get(chat_id=message.chat.id) except ChatLink.DoesNotExist: pass else: link = obj.link bot.reply_to(message, f'Ссылка: "{link}"') @bot.message_handler(func=lambda msg: not checkers.is_url(msg.text)) def all_text(message): bot.reply_to(message, message.text) if __name__ == '__main__': thread = Thread(target=pereodic_send_links) thread.start() bot.polling(none_stop=True, interval=0)