pogobot.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:PogomBOT 作者: eugenio412 项目源码 文件源码
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]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号