def location(bot, update): urld = 'http://api.citysdk.waag.org/layers/parking.garage/objects?per_page=25' user = User.objects.get(chat_id=update.message.chat_id) User.objects.filter(chat_id=update.message.chat_id).update( lastCommand="parking") cronologyHandler.createCronology(bot, update, user) r = urllib.request.urlopen(urld) data = json.loads(r.read().decode(r.info().get_param('charset') or 'utf-8')) closestParkings, closestDistance = calculate_parkings_distance( bot, update, data['features']) print(closestDistance) url, keyboard = utility.getDecoratedMap(bot, update, closestParkings, data['features'], closestDistance) reply_markup = InlineKeyboardMarkup(keyboard, one_time_keyboard=True, resize_keyboard=True) #bot.sendPhoto(chat_id = update.message.chat_id, photo=url) bot.sendMessage(chat_id=update.message.chat_id, text="Choose for more details: ", reply_markup=reply_markup) reply_markup = telegram.ReplyKeyboardRemove() #bot.sendMessage(chat_id = update.message.chat_id, text="Type /parking to start another search.", reply_markup=reply_markup) #sendMessageForParkings(closestParkings, data['features'], bot, update) userHandler.setUserBotActived(update.message.chat_id, True)
def chargePoint(bot, update): user = User.objects.get(chat_id=update.message.chat_id) User.objects.filter(chat_id=update.message.chat_id).update(lastCommand = "chargePoint") cronologyHandler.createCronology(bot, update, user) locationGPS_keyboard = KeyboardButton(text="Send my GPS location", request_location=True) locationUser_keyboard = KeyboardButton(text="Choose another location") custom_keyboard = [[ locationGPS_keyboard], [locationUser_keyboard]] addPreferencesKeyboard(custom_keyboard, user) reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard, resize_keyboard=True, one_time_keyboard=True) bot.sendMessage(chat_id=update.message.chat_id, text="Would you mind sharing your location to search the closest charge point?", reply_markup=reply_markup)
def location(bot, update): urld = 'https://kaart.amsterdam.nl/datasets/datasets-item/t/parkeerlocaties-1/export/json' user = User.objects.get(chat_id=update.message.chat_id) User.objects.filter(chat_id=update.message.chat_id).update(lastCommand="chargePoint") cronologyHandler.createCronology(bot, update, user) r = urllib.request.urlopen(urld) data = json.loads(r.read().decode(r.info().get_param('charset') or 'utf-8')) closestChargePoints, closestDistance = calculate_charge_point_distance(bot, update, data['features']); url, keyboard = utility.getDecoratedMap(bot, update, closestChargePoints, data['features'], closestDistance) reply_markup = InlineKeyboardMarkup(keyboard, one_time_keyboard=True, resize_keyboard=True) bot.sendMessage(chat_id = update.message.chat_id, text="Choose for more details: ", reply_markup=reply_markup) reply_markup = telegram.ReplyKeyboardRemove() userHandler.setUserBotActived(update.message.chat_id, True)