Ejemplo n.º 1
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}
Ejemplo n.º 2
0
def doGmCommand(characterId, content):
    if content.startswith('\\'):
        chater = ChaterManager().getChaterByCharacterId(characterId)
        if chater:
            roomId = chater.getRoomId()
            if roomId < 5000:
                childnode = 200000 + roomId
                GlobalObject().root.callChild("scense_1000", "GmCommand",
                                              characterId, content)
                return True
    return False
Ejemplo n.º 3
0
def doGmCommand(characterId,content):
    if content.startswith('\\'):
        chater = ChaterManager().getChaterByCharacterId(characterId)
        if chater:
            roomId = chater.getRoomId()
            if roomId<5000:
                childnode = 200000 + roomId
#                chatroot.callChild(201000,'GmCommand',characterId,content)
                GlobalObject().root.callChild("scense_1000","GmCommand",characterId,content)
                return True
    return False
Ejemplo n.º 4
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}
Ejemplo n.º 5
0
def leaveRoom(characterId):
    '''
    @param characterId: int character id
    @param roomId: int room id
    '''
    chater = ChaterManager().getChaterByCharacterId(characterId)
    if not chater:
        return
    clientId = chater.getDynamicId()
    oldroomId = chater.getRoomId()
    if not oldroomId or clientId < 0:
        return
    if oldroomId :
        ChatRoomManager().leaveRoom(clientId, oldroomId)
Ejemplo n.º 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()

    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}
Ejemplo n.º 7
0
def JoinRoom(characterId,roomId,scenename):
    '''
    @param characterId: int character id
    @param roomId: int room id
    '''
    chater = ChaterManager().addChaterByid(characterId)
    if not chater:
        return
    clientId = chater.getDynamicId()
    oldroomId = chater.getRoomId()
    chater.setSceneName(scenename)
    if not oldroomId or clientId < 0:
        return
    if oldroomId :
        ChatRoomManager().leaveRoom(clientId, oldroomId)
    chater.setRoomId(roomId)
    ChatRoomManager().joinRoom(clientId, roomId)
Ejemplo n.º 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}