def cmd_radius(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
# Check if user has set a location
user_location = pref.get('location')
if user_location[0] is None:
bot.sendMessage(chat_id, text="You have not sent a location. Do that first!")
return
# Get the users location
logger.info('[%s] Retrieved Location as Lat %s, Lon %s, R %s (Km)' % (
chat_id, user_location[0], user_location[1], user_location[2]))
if len(args) < 1:
bot.sendMessage(chat_id, text="Current scan location is: %f / %f with radius %.2f m"
% (user_location[0], user_location[1], user_location[2]))
return
# Change the radius
pref.set('location', [user_location[0], user_location[1], float(args[0])/1000])
logger.info('[%s] Set Location as Lat %s, Lon %s, R %s (Km)' % (chat_id, pref['location'][0],
pref['location'][1], pref['location'][2]))
# Send confirmation
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]))
评论列表
文章目录