def pushChatToObjectList(id,tid):
	'''推送私聊角色列表'''
	from app.chatServer.core.ChaterManager import ChaterManager
	from app.chatServer.core.ChaterLogManager import ChaterLogManager
	response=ChatToObjectListInfo1010_pb2.ChatToObjectListResponse()
	clog=ChaterLogManager().addChatLog(id)#获取聊天类
	listid=clog.getFriends()#获取角色私聊对象id列表
	if len(listid)<0:
		return
	gamer=ChaterManager().getChaterByCharacterId(id)
	if not gamer:
		return
	gamerid=gamer.getDynamicId()
	for cid in listid:
		gamer1=ChaterManager().getChaterByCharacterId(cid)
		info=response.chatObjectInfo.add()
		info.chatObjectId=cid
		info.name=gamer1.getCharacterName()
		info.level=str(gamer1.level)
		if gamer1.island:
			info.chatObjectPos=gamer1.scenename
		else:
			info.chatObjectPos=lg().g(106)
		info.readFlag=ChaterLogManager().getFriendReaderState(id,cid)
	msg=response.SerializeToString()
	pushApplyMessage(1010,msg,[gamer1])
def pushChatToObjectList(id,tid):
    '''推送私聊角色列表'''
    from app.chatServer.core.ChaterManager import ChaterManager
    from app.chatServer.core.ChaterLogManager import ChaterLogManager
    response=ChatToObjectListInfo1010_pb2.ChatToObjectListResponse()
    clog=ChaterLogManager().addChatLog(id) #获取聊天类
    listid=clog.getFriends()#获取角色私聊对象id列表
    if len(listid)<0:
        return
    player=ChaterManager().getChaterByCharacterId(id)
#    player=PlayersManager().getPlayerByID(id)
    if not player:
        #print "推送私聊角色列表时没有角色"+str(id)
        return 
    #print "角色私聊角色列表发送给"+player.baseInfo.getNickName()
    playerid=player.getDynamicId()
    for cid in listid:
        player1=ChaterManager().getChaterByCharacterId(cid)
        info=response.chatObjectInfo.add()
        info.chatObjectId=cid
        info.name=player1.getCharacterName()
        #print "私聊信息角色列表:"+player1.baseInfo.getNickName()
        info.level=str(player1.level)
        info.perfession=player1.getProfessionName()
        if player1.island:
                info.chatObjectPos=player1.scenename
        else:
            info.chatObjectPos=Lg().g(106)
        info.readFlag=ChaterLogManager().getFriendReaderState(id, cid)
    #print "------------------------------------------------------------------"
    msg = response.SerializeToString()
    pushApplyMessage(1010,msg,[playerid])
Example #3
0
def SendChatMessageRequest_1013(dynamicId, request_proto):
    '''当前角色发送私聊信息'''
    import time
    from app.chatServer.core.ChaterManager import ChaterManager
    argument = SendChatMessage1013_pb2.SendChatMessageRequest()
    argument.ParseFromString(request_proto)
    response = SendChatMessage1013_pb2.SendChatMessageResponse()
    id = argument.id
    tid = argument.chatId
    context = argument.chatMessage
    
    chater=ChaterManager().getChaterByCharacterId(id)
    if chater.donttalk==0:#不禁言
        timet=str(time.strftime('%Y-%m-%d %X'))
        title="<font color='#ffffff'>"
        title+=chater.getCharacterName()
        title+=":</font><br/>"
        title+=u"<font color='#ffffff'>&nbsp;&nbsp;%s</font><br/>"%context
        ChaterLogManager().addLog(id, tid, title,timet)
        response.result =True
        response.message =u''
    else:#禁言
        response.result =True
        response.message =Lg().g(644)
    return response.SerializeToString()
def pushChatToObjectList(id, tid):
    '''推送私聊角色列表'''
    from app.chatServer.core.ChaterManager import ChaterManager
    from app.chatServer.core.ChaterLogManager import ChaterLogManager
    response = ChatToObjectListInfo1010_pb2.ChatToObjectListResponse()
    clog = ChaterLogManager().addChatLog(id)  #获取聊天类
    listid = clog.getFriends()  #获取角色私聊对象id列表
    if len(listid) < 0:
        return
    gamer = ChaterManager().getChaterByCharacterId(id)
    if not gamer:
        return
    gamerid = gamer.getDynamicId()
    for cid in listid:
        gamer1 = ChaterManager().getChaterByCharacterId(cid)
        info = response.chatObjectInfo.add()
        info.chatObjectId = cid
        info.name = gamer1.getCharacterName()
        info.level = str(gamer1.level)
        if gamer1.island:
            info.chatObjectPos = gamer1.scenename
        else:
            info.chatObjectPos = lg().g(106)
        info.readFlag = ChaterLogManager().getFriendReaderState(id, cid)
    msg = response.SerializeToString()
    pushApplyMessage(1010, msg, [gamer1])
Example #5
0
def SendChatMessageRequest_1013(dynamicId, request_proto):
    '''当前角色发送私聊信息'''
    import time
    from app.chatServer.core.ChaterManager import ChaterManager
    argument = SendChatMessage1013_pb2.SendChatMessageRequest()
    argument.ParseFromString(request_proto)
    response = SendChatMessage1013_pb2.SendChatMessageResponse()
    id = argument.id
    tid = argument.chatId
    context = argument.chatMessage

    chater = ChaterManager().getChaterByCharacterId(id)
    if chater.donttalk == 0:  #不禁言
        timet = str(time.strftime('%Y-%m-%d %X'))
        title = "<font color='#ffffff'>"
        title += chater.getCharacterName()
        title += ":</font><br/>"
        title += u"<font color='#ffffff'>&nbsp;&nbsp;%s</font><br/>" % context
        ChaterLogManager().addLog(id, tid, title, timet)
        response.result = True
        response.message = u''
    else:  #禁言
        response.result = True
        response.message = Lg().g(644)
    return response.SerializeToString()
Example #6
0
def sendMessage(dynamicId,
                characterId,
                topic,
                content,
                linkData,
                tonickname=None):
    '''发送聊天信息
    @param dynamicId: int 客户端的id
    @param characterId: int 角色的id
    @param topic: int 频道的编号    
    @param content: string 发送的消息内容
    @param linkData: dict list 连接信息内容
    '''

    chater = ChaterManager().getChaterByCharacterId(characterId)
    if not chater:
        return {'result': False, 'message': Lg().g(639)}
    if topic == 7:
        toplayer = ChaterManager().getChaterByCharacterId(characterId)
        if not toplayer:
            return {'result': False, "message": Lg().g(640)}
        else:
            topic = toplayer.baseInfo.id

    targetList = []
    chaterName = chater.getCharacterName()
    profession = chater.getProfession()

    if topic == 1:  #世界频道聊天
        idlist = ChaterManager().getAlldynamicId()
        targetList = idlist
    elif topic == 2:  #当前 相当于同场景
        roomId = chater.getRoomId()
        targetList = ChatRoomManager().getRoomMember(roomId)

    elif topic == 3:  #国
        gid = chater.guildid
        if gid < 1:
            return {'result': False, "message": Lg().g(641)}
        else:
            #            return {'result':False,"message":u"国聊天功能暂未开放,敬请期待"}
            #            idlist = ChaterManager().getAlldynamicId()
            #            targetList=idlist
            #            content=u"国聊天暂未开放"
            plist = GuildManager().getdtidListBygid(gid)
            if plist:
                targetList = list(plist)


#        gid=player.guild.getID()#返回行会id
#        resut=setGuildPlayerDynamicId(gid,targetList) #设置添加targetList,国聊天角色动态id列表,返回是否成功
#        if not resut:
#            return {'result':False,"message":Lg().g(641)}
    result = doGmCommand(characterId, content)
    #    if not result:
    pushChatMessage(topic, characterId, chaterName, profession,
                    dbshieldword.replaceIllegalChar(content), linkData,
                    targetList)
    return {'result': True}
Example #7
0
def sendMessage(dynamicId,characterId,topic,content,linkData,tonickname=None):
    '''发送聊天信息
    @param dynamicId: int 客户端的id
    @param characterId: int 角色的id
    @param topic: int 频道的编号    
    @param content: string 发送的消息内容
    @param linkData: dict list 连接信息内容
    '''

    chater = ChaterManager().getChaterByCharacterId(characterId)
    if not chater:
        return {'result':False,'message':Lg().g(639)}
    if topic==7:
        toplayer=ChaterManager().getChaterByCharacterId(characterId)
        if not toplayer:
            return {'result':False,"message":Lg().g(640)}
        else:
            topic=toplayer.baseInfo.id
        
    targetList = []
    chaterName = chater.getCharacterName()
    profession = chater.getProfession()
    
    if topic==1: #世界频道聊天
        idlist = ChaterManager().getAlldynamicId()
        targetList=idlist
    elif topic==2:#当前 相当于同场景
        roomId = chater.getRoomId()
        targetList = ChatRoomManager().getRoomMember(roomId)

    elif topic==3:#国
        gid=chater.guildid
        if gid<1:
            return {'result':False,"message":Lg().g(641)}
        else:
#            return {'result':False,"message":u"国聊天功能暂未开放,敬请期待"}
#            idlist = ChaterManager().getAlldynamicId()
#            targetList=idlist
#            content=u"国聊天暂未开放"
            plist=GuildManager().getdtidListBygid(gid)
            if plist:
                targetList=list(plist)
                
#        gid=player.guild.getID()#返回行会id
#        resut=setGuildPlayerDynamicId(gid,targetList) #设置添加targetList,国聊天角色动态id列表,返回是否成功
#        if not resut:
#            return {'result':False,"message":Lg().g(641)}
    result = doGmCommand(characterId,content)
#    if not result:
    pushChatMessage(topic,characterId, chaterName, profession,
                     dbshieldword.replaceIllegalChar(content),linkData, targetList)
    return {'result':True}
Example #8
0
def sendMessage(dynamicId,
                characterId,
                topic,
                content,
                linkData,
                tonickname=None):
    '''发送聊天信息
	@param dynamicId:int 客户端的id
	@param characterId:int 角色的id
	@param topic :int 频道的编号
	@param content:string 发送的消息内容
	@param linkData: dict list 连接信息内容
	'''

    chater = ChaterManager().getChaterByCharacterId(characterId)
    if not chater:
        return {'result': False, 'message': Lg().g(639)}
    if topic == 7:
        toplayer = ChaterManager().getChaterByCharacterId(characterId)
        if not toplayer:
            return {'result': False, "message": Lg().g(640)}
        else:
            topic = toplayer.baseInfo.id

    targetList = []
    chaterName = chater.getCharacterName()

    if topic == 1:  #世界聊天
        idlist = ChaterManager().getAlldynamicId()
        targetList = idlist
    elif topic == 2:  #当前场景
        roomId = chater.getRoomId()
        targetList = ChatRoomManager().getRoomMember(roomId)
    elif topic == 3:  #公会
        gid = chater.guildid
        if gid < 1:
            return {'result': False, "message": Lg().g(641)}
        else:
            plist = GuildManager().getdtidListBygid(gid)
            if plist:
                targetList = list(plist)

    result = doGmCommand(characterId, content)

    pushChatMessage(topic, characterId, chaterName,
                    dbShieldWord.replaceIllegalChar(content), linkData,
                    targetList)
    return {'result': True}
Example #9
0
def sendMessage(dynamicId,characterId,topic,content,linkData,tonickname=None):
	'''发送聊天信息
	@param dynamicId:int 客户端的id
	@param characterId:int 角色的id
	@param topic :int 频道的编号
	@param content:string 发送的消息内容
	@param linkData: dict list 连接信息内容
	'''

	chater=ChaterManager().getChaterByCharacterId(characterId)
	if not chater:
		return {'result':False,'message':Lg().g(639)}
	if topic==7:
		toplayer=ChaterManager().getChaterByCharacterId(characterId)
		if not toplayer:
			return {'result':False,"message":Lg().g(640)}
		else:
			topic=toplayer.baseInfo.id

	targetList=[]
	chaterName=chater.getCharacterName()

	if topic==1:#世界聊天
		idlist=ChaterManager().getAlldynamicId()
		targetList=idlist
	elif topic==2:#当前场景
		roomId=chater.getRoomId()
		targetList=ChatRoomManager().getRoomMember(roomId)
	elif topic==3:#公会
		gid=chater.guildid
		if gid<1:
			return {'result':False,"message":Lg().g(641)}
		else:
			plist=GuildManager().getdtidListBygid(gid)
			if plist:
				targetList=list(plist)

	result=doGmCommand(characterId,content)

	pushChatMessage(topic,characterId,chaterName,dbShieldWord.replaceIllegalChar(content),linkData,targetList)
	return {'result':True}