def cmd_location_str(bot, update,args):
chat_id = update.message.chat_id
pref = prefs.get(chat_id)
if chat_id not in jobs:
bot.sendMessage(chat_id, text='You have no active scanner.')
return
if len(args) <= 0:
bot.sendMessage(chat_id, text='You have not supplied a location')
return
try:
user_location = geolocator.geocode(' '.join(args))
except Exception as e:
logger.error('[%s] %s' % (chat_id, repr(e)))
bot.sendMessage(chat_id, text='Location not found, or openstreetmap is down.')
return
# We set the location from the users sent location.
pref.set('location', [user_location.latitude, user_location.longitude, location_radius])
logger.info('[%s] Setting scan location to Lat %s, Lon %s, R %s' % (chat_id,
pref['location'][0], pref.preferences['location'][1], pref.preferences['location'][2]))
# Send confirmation nessage
bot.sendMessage(chat_id, text="Setting scan location to: %f / %f with radius %.2f m" %
(pref['location'][0], pref['location'][1], 1000*pref['location'][2]))
评论列表
文章目录