simplifiedapp.py 文件源码

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

项目:nba-stats-twilio-sms-bot 作者: elizabethsiegle 项目源码 文件源码
def send_sms():
    msg = request.form['Body'].lower() # convert to lowercase
    msg = "send 1st + last names of 2 players followed by a stat (GP,W,L,MIN,PTS,FG%,3P%,FT%,REB,AST,STL,BLK). Check for typos!"
    player_and_stat = msg.split() #split 

    if len(player_and_stat) == 5: # check input: 2 players + stat
        stat = player_and_stat.pop()
        player1 = " ".join(player_and_stat[:2])
        player1 = " ".join(player_and_stat[2:])

        player_stat_map = dict(parse_data(stat))

        player1_stats = player_stat_map.get(player1)
        player2_stats = player_stat_map.get(player2)

        if player1_stats and player2_stats:
            msg = "{0}'s total, higher than {1}'s"
            if player2_stats > player1_stats:
                msg = "{1}'s total, higher than {0}'s"
            msg = msg.format([player1_stats, player2_stats])

        else: #check
            msg = "check both players' names (first and last!)"

    return MessagingResponse().message(msg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号