def show_latestgame():
    gameinfo = dba.get_latestgames()
    if gameinfo:
        info = u"""地点: %s \n日期: %s \n时间: %s \n参与球星: %s""" % (gameinfo.location, str(gameinfo.date), str(gameinfo.time), str(dba.get_usersbygameid(gameinfo.id)))
        return info
    else:
        info = u"""目前没有比赛被创建~"""
        return info
Beispiel #2
0
def show_latestgame():
    gameinfo = dba.get_latestgames()
    if gameinfo:
        info = u"""地点: %s \n日期: %s \n时间: %s \n参与球星: %s""" % (
            gameinfo.location, str(gameinfo.date), str(
                gameinfo.time), str(dba.get_usersbygameid(gameinfo.id)))
        return info
    else:
        info = u"""目前没有比赛被创建~"""
        return info
Beispiel #3
0
def handleRule(msg):
    key = msg['Content'][0:2].lower()
    content = msg['Content'][3:]
    if key == Keyword['apply']:
        name = u'%s' % (msg['FromUserName'])
        #update the user_info with the latest game id
        user_info = dba.get_username(name)
        gameinfo = dba.get_latestgames()
        if user_info:
            #TODO: update the user_info with the new name
            if user_info.game_id == gameinfo.id:
                return response_news_msg(msg, u"""山炮啊,你已经报名过了!""")
            else:
                dba.update_usergame(name, str(user_info.name), gameinfo.id)
                info = u'给力啊!报名成功\n以下是活动信息:\n%s' % (show_latestgame())
                return response_news_msg(msg, info)
        else:
            return response_news_msg(
                msg, u"""哥,别着急,先注册一下球员信息呗~\n发送zc+空格+英文昵称 : 注册成为队员""")
    if key == Keyword['friend']:
        if content:
            gameinfo = dba.get_latestgames()
            friend = dba.get_username(content)
            print friend
            if friend:
                dba.update_usergame(content, content, gameinfo.id)
                return response_news_msg(msg, u'谢谢帮朋友报名!')
            else:
                dba.insert_userinfo(content, content, gameinfo.id)
                return response_news_msg(msg, u'谢谢你介绍新朋友过来!')
        else:
            return response_news_msg(msg, u'你要帮谁报名?请发送 py+空格+朋友姓名!')
    elif key == Keyword['quitgame']:
        name = u'%s' % (msg['FromUserName'])
        #update the user_info with the latest game id
        user_info = dba.get_username(name)
        gameinfo = dba.get_latestgames()
        if user_info:
            #TODO: update the user_info with the new name
            if user_info.game_id == gameinfo.id:
                dba.update_usergame(name, str(user_info.name), 0)
                return response_news_msg(msg, u"""您已经取消报名!人品-1""")
            else:
                return response_news_msg(msg, u"""你还没有报名,怎么取消?""")
        else:
            return response_news_msg(msg, u"""你没注册,当然也不能取消报名了,请先注册然后完成报名""")
    elif key == Keyword['create_game']:
        #split location ,date and time
        array = content.split(' ')
        if len(array) < 3:
            return help_info(msg)
        #id accurate limit to second is enought


#        location = u'%s' % array[0]
        dba.insert_game(int(time.time()), array[0], array[1], array[2])
        return response_news_msg(msg, u"""活动创建成功!""")
    elif key == Keyword['showgame']:
        name = u'%s' % (msg['FromUserName'])
        user_info = dba.get_username(name)
        if user_info:
            return response_news_msg(msg, show_latestgame())
        else:
            return response_news_msg(msg,
                                     u'你还没注册,不能查看最新活动~请发送zc+空格+姓名 注册为潮白风云队员')
    elif key == Keyword['register']:
        name = u'%s' % (msg['FromUserName'])
        #update the user_info with the latest game id
        user_info = dba.get_username(name)
        if user_info:
            return response_news_msg(msg, u"你已经是在册球员,请不要重复注册")
        if content:
            dba.insert_userinfo(msg['FromUserName'], content, 0)
        else:
            return response_news_msg(msg, u"昵称不能为空,请输入:zc+空格+英文昵称")
        return response_news_msg(msg, u"""注册成功!""")
    elif key == Keyword['unregister']:
        dba.del_user_info(msg['FromUserName'])
        return response_news_msg(msg, u"""注销成功!""")
    elif key == Keyword['game']:
        return response_news_msg(msg,
                                 u"""游戏功能尚未开通,请多提反馈意见!\n发送fk+空格+内容:本助理洗耳恭听""")
    else:
        return response_news_msg(msg, u"""无聊?回复'?' 获取帮助""")
def handleRule(msg):
    key = msg['Content'][0:2].lower()
    content = msg['Content'][3:]
    if key == Keyword['apply']:
        name = u'%s' % (msg['FromUserName'])
        #update the user_info with the latest game id
        user_info = dba.get_username(name)
        gameinfo = dba.get_latestgames()
        if user_info:
            #TODO: update the user_info with the new name
            if user_info.game_id == gameinfo.id:
                return response_news_msg(msg, u"""山炮啊,你已经报名过了!""")
            else:
                dba.update_usergame(name, str(user_info.name), gameinfo.id)
                info = u'给力啊!报名成功\n以下是活动信息:\n%s' % (show_latestgame())
                return response_news_msg(msg, info)
        else:
            return response_news_msg(msg, u"""哥,别着急,先注册一下球员信息呗~\n发送zc+空格+英文昵称 : 注册成为队员""")
    if key == Keyword['friend']:
        if content:
            gameinfo = dba.get_latestgames()
            friend = dba.get_username(content)
            print friend
            if friend:
                dba.update_usergame(content, content, gameinfo.id)
                return response_news_msg(msg, u'谢谢帮朋友报名!')
            else:
                dba.insert_userinfo(content, content, gameinfo.id)
                return response_news_msg(msg, u'谢谢你介绍新朋友过来!')
        else:
            return response_news_msg(msg, u'你要帮谁报名?请发送 py+空格+朋友姓名!')
    elif key == Keyword['quitgame']:
        name = u'%s' % (msg['FromUserName'])
        #update the user_info with the latest game id
        user_info = dba.get_username(name)
        gameinfo = dba.get_latestgames()
        if user_info:
            #TODO: update the user_info with the new name
            if user_info.game_id == gameinfo.id:
                dba.update_usergame(name, str(user_info.name), 0)
                return response_news_msg(msg, u"""您已经取消报名!人品-1""")
            else:
                return response_news_msg(msg, u"""你还没有报名,怎么取消?""")
        else:
            return response_news_msg(msg, u"""你没注册,当然也不能取消报名了,请先注册然后完成报名""")
    elif key == Keyword['create_game']:
        #split location ,date and time
        array = content.split(' ')
        if len(array) < 3:
                return help_info(msg)
        #id accurate limit to second is enought
#        location = u'%s' % array[0]
        dba.insert_game(int(time.time()), array[0], array[1], array[2])
        return response_news_msg(msg, u"""活动创建成功!""")
    elif key == Keyword['showgame']:
        name = u'%s' % (msg['FromUserName'])
        user_info = dba.get_username(name)
        if user_info:
            return response_news_msg(msg, show_latestgame())
        else:
            return response_news_msg(msg, u'你还没注册,不能查看最新活动~请发送zc+空格+姓名 注册为潮白风云队员')
    elif key == Keyword['register']:
        name = u'%s' % (msg['FromUserName'])
        #update the user_info with the latest game id
        user_info = dba.get_username(name)
        if user_info:
            return response_news_msg(msg, u"你已经是在册球员,请不要重复注册")
        if content:
            dba.insert_userinfo(msg['FromUserName'], content, 0)
        else:
            return response_news_msg(msg, u"昵称不能为空,请输入:zc+空格+英文昵称")
        return response_news_msg(msg, u"""注册成功!""")
    elif key == Keyword['unregister']:
        dba.del_user_info(msg['FromUserName'])
        return response_news_msg(msg, u"""注销成功!""")
    elif key == Keyword['game']:
        return response_news_msg(msg, u"""游戏功能尚未开通,请多提反馈意见!\n发送fk+空格+内容:本助理洗耳恭听""")
    else:
        return response_news_msg(msg, u"""无聊?回复'?' 获取帮助""")