def send_evolution(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) evolution_graph = requests.get(config.api_url + '/evolution').content with open('evolution.png', 'wb') as f: f.write(evolution_graph) try: bot.send_photo(uid, open('evolution.png', 'rb')) except ApiException: registeruser(cid, username) return bot.send_chat_action(cid, 'typing') recuperados_graph = requests.get(config.api_url + '/evolution_recuperados').content with open('evolution_recuperados.png', 'wb') as f: f.write(recuperados_graph) bot.send_photo(uid, open('evolution_recuperados.png', 'rb')) bot.send_chat_action(cid, 'typing') fallecidos_graph = requests.get(config.api_url + '/evolution_fallecidos').content with open('evolution_fallecidos.png', 'wb') as f: f.write(fallecidos_graph) bot.send_photo(uid, open('evolution_fallecidos.png', 'rb'))
def send_provincias(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) provincias_graph = requests.get(config.api_url + '/provincias').content with open('provincias.png', 'wb') as f: f.write(provincias_graph) try: bot.send_photo(uid, open('provincias.png', 'rb')) except ApiException: registeruser(cid, username) return bot.send_chat_action(cid, 'typing') municipios_graph = requests.get(config.api_url + '/municipios').content with open('municipios.png', 'wb') as f: f.write(municipios_graph) bot.send_photo(uid, open('municipios.png', 'rb'))
def send_summary(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) try: bot.send_message(uid, summary()) except ApiException: registeruser(cid, username) return bot.send_chat_action(cid, 'typing') graph1 = requests.get(config.api_url + '/summary_graph1').content with open('summary1.png', 'wb') as f: f.write(graph1) bot.send_photo(uid, open('summary1.png', 'rb')) bot.send_chat_action(cid, 'typing') graph2 = requests.get(config.api_url + '/summary_graph2').content with open('summary2.png', 'wb') as f: f.write(graph2) bot.send_photo(uid, open('summary2.png', 'rb'))
def channel_start(message): cid = message.chat.id mdb.savechat(cid) bot.send_message( cid, 'Se ha activado ☢️🇨🇺 Covid19 Cuba Bot 🇨🇺☢️ para este canal. (@covid19cubadata_bot)' )
def about_handler(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) try: bot.send_message(uid, about()) except ApiException: registeruser(cid, username)
def start_summary(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) try: bot.send_message( uid, summary(), ) except ApiException: registeruser(cid, username)
def simple_start(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) try: bot.send_message( uid, '☢️🇨🇺 Covid19 Cuba Bot 🇨🇺☢️\n\nHola {}, espero se encuentre bien de salud.\nSeleccione una opción del teclado para obtener información sobre el estado de Cuba con respecto al SARS-COV2 (COVID19)' .format(username), reply_markup=markup) except ApiException: registeruser(cid, username)
def send_test(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) test_graph = requests.get(config.api_url + '/test').content with open('test.png', 'wb') as f: f.write(test_graph) try: bot.send_photo(uid, open('test.png', 'rb')) except ApiException: registeruser(cid, username)
def send_sexo(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) sexo_graph = requests.get(config.api_url + '/sexo').content data = requests.get(config.api_url + '/sexo_text').json() with open('sexo.png', 'wb') as f: f.write(sexo_graph) texto = 'Hombres: {} | Mujeres {}'.format(data['hombres'], data['mujeres']) try: bot.send_photo(uid, open('sexo.png', 'rb'), texto) except ApiException: registeruser(cid, username)
def send_nacionalidad(message): cid = message.chat.id uid = message.from_user.id username = '******'.format(message.from_user.first_name, message.from_user.username) bot.send_chat_action(cid, 'typing') mdb.savechat(cid) nacionalidad_graph = requests.get(config.api_url + '/nacionalidad').content data = requests.get(config.api_url + '/nacionalidad_text').json() with open('nacionalidad.png', 'wb') as f: f.write(nacionalidad_graph) texto = 'Cubanos: {} | Extranjeros {}'.format(data['Cubanos'], data['Extranjeros']) try: bot.send_photo(uid, open('nacionalidad.png', 'rb'), texto) except ApiException: registeruser(cid, username)
def channel_summary(message): cid = message.chat.id mdb.savechat(cid) bot.send_message(cid, summary())