Example #1
0
    def InsMessage(self,param={}):
        '''
                    发送邮件
        '''
        import sys;reload(sys);sys.setdefaultencoding('utf8')
        
        optId=18006
        
        toUserNickNames = param['ToUserNickNames']    #收件人昵称字符串
        subject=param['Subject']
        content=param['Content']
        
        
        mailCfg = Gcore.loadCfg(Gcore.defined.CFG_MAIL)
        subjectMin = mailCfg['SubjectMin'] #主题最小字符数
        subjectMax = mailCfg['SubjectMax'] #主题最大字符数
        contentMin = mailCfg['ContentMin']
        contentMax = mailCfg['ContentMax']
        toUserMax = mailCfg['MailSendMax'] #同时发送邮件最大数量
        
        toUserNickNames = escapeSplit(toUserNickNames) #解析昵称字符串
        inexistUserNickNames = self.mod.inexistNickName(toUserNickNames)  #过滤收件人
        
        toUserIds = self.mod.getToUserId(toUserNickNames) #根据昵称,得到玩家id
        
        #最多同时发送邮件给五个玩家,最少一个
        numToUserId = len(toUserIds)
        if numToUserId>toUserMax:
            #不能超过5个玩家
            return Gcore.error(optId, -18006001)
        
        #过滤主题和邮件内容
        subject=filterInput(subject,subjectMin,subjectMax,b_Replace=True,b_chat = True)
        if subject==-1:
            return Gcore.error(optId, -18006993)#长度不符合要求
        if subject==-2:
            return Gcore.error(optId, -18006991)#特殊字符
        content=filterInput(content,contentMin,contentMax,b_Replace=True,b_chat = True)
        if content==-1:
            return Gcore.error(optId, -18006993)#长度不符合要求
        if content==-2:
            return Gcore.error(optId, -18006991)#特殊字符
#        if not filterInput(subject,subjectMin,subjectMax) and not filterInput(content,contentMin,contentMax):
#            return Gcore.error(optId, -18006002) #不满足要求,长度,特殊字符,敏感字符'
        if self.uid in toUserIds:
            return Gcore.error(optId, -18006002)#不能发信息给自己
        param['ToUserIds'] = toUserIds
        result=self.mod.sendMail(toUserIds,subject,content,2)
        
#        body ={'result':result,'inexistUserId':inexistUserId}        
        body = {'result':result,'InexistNames':inexistUserNickNames}
        
        recordData = {'uid':self.uid,'ValType':numToUserId,'Val':1}#成就,任务记录
        return Gcore.out(optId, body = body,mission=recordData)
Example #2
0
 def ModifyClub(self, p={}):
     '''
     :修改军团信息(团长)
     '''
     optId = 15065
     logoId = p.get('LogoId')
     clubNotice = p.get('ClubNotice')
     allowState = p.get('AllowState')
     building = self.mod.getClubBuildingInfo()
     if building is None:
         return Gcore.error(optId, -15065901)  #外史院建筑不存在
     cfgClub = Gcore.loadCfg(defined.CFG_BUILDING_CLUB)
     noticeLimit = cfgClub.get('ClubNoticeLimit')
     flag = com.filterInput(clubNotice, 0, noticeLimit)
     if flag == -1:
         return Gcore.error(optId, -15065993)  #长度不符合要求
     elif flag == -2:
         return Gcore.error(optId, -15065992)  #不能含有敏感字符
     if logoId not in range(1, 7):
         return Gcore.error(optId, -15065999)  #参数错误
     clubId = self.mod.getUserClubId()
     if not clubId:
         return Gcore.error(optId, -15065920)  #军团不存在
     clubLeader = self.mod.getClubLeader(clubId)
     if self.uid != clubLeader.get('UserId'):
         return Gcore.error(optId, -15065998)  #非法权限
     data = {
         'ClubLogoId': logoId,
         'ClubNotice': clubNotice,
         'AllowState': allowState
     }
     self.mod.modifyClub(clubId, data)
     return Gcore.out(optId, data)
Example #3
0
 def ModifyClub(self,p={}):
     '''
     :修改军团信息(团长)
     '''
     optId = 15065
     logoId = p.get('LogoId')
     clubNotice = p.get('ClubNotice')
     allowState = p.get('AllowState')
     building = self.mod.getClubBuildingInfo()
     if building is None:
         return  Gcore.error(optId,-15065901)#外史院建筑不存在
     cfgClub = Gcore.loadCfg(defined.CFG_BUILDING_CLUB)
     noticeLimit = cfgClub.get('ClubNoticeLimit')
     flag = com.filterInput(clubNotice,0,noticeLimit)
     if flag == -1:
         return Gcore.error(optId, -15065993) #长度不符合要求
     elif flag == -2:
         return Gcore.error(optId, -15065992) #不能含有敏感字符
     if logoId not in range(1,7):
         return Gcore.error(optId,-15065999)#参数错误
     clubId = self.mod.getUserClubId()
     if not clubId:
         return Gcore.error(optId,-15065920)#军团不存在
     clubLeader = self.mod.getClubLeader(clubId)
     if self.uid != clubLeader.get('UserId'):
         return Gcore.error(optId,-15065998)#非法权限
     data = {'ClubLogoId':logoId,'ClubNotice':clubNotice,'AllowState':allowState}
     self.mod.modifyClub(clubId,data)
     return Gcore.out(optId,data)
Example #4
0
    def CreateRole(self, p={}):
        '''注册用户 by zhanggh'''
        AccountId = p.get('TotalServiceId')
        nickName = p.get('NickName')
        camp = p.get('UserCamp')
        userIcon = p.get('UserIcon')
        OldAccount = p.get('OldAccount')  #是否老用户

        if (not AccountId) or (not nickName) or (not camp) or (not userIcon):
            return -10002999  #参数错误

        PlayerCfg = Gcore.loadCfg(Gcore.defined.CFG_PLAYER)
        nickNameMin = PlayerCfg.get('NickNameMin')
        nickNameMax = PlayerCfg.get('NickNameMax')

        flag = filterInput(nickName, nickNameMin, nickNameMax)
        if flag == -1:
            return -10002993  #字数字数限制
        elif flag == -2:
            return -10002991  #特殊字符
        elif flag == -3:
            return -10002992  #敏感字

        if camp not in [1, 2, 3]:
            return -10002004  #阵营不正确

        if userIcon not in [1, 2, 3, 4, 5]:
            return -10002005  #头像不正确

        print 'CheckNickName', flag

        #获取用户ID,暂时没有角色UserId才能注册
        UserId = self.getUserIdByAccount(AccountId)
        if not UserId:  #没有用户注册一个,建立AccountId与Uid关系,创建用户
            #验证用户昵称
            hasSameName = self.db.out_field('tb_user', 'Count(1)',
                                            "NickName='%s'" % nickName)
            if hasSameName:
                return -10002001  #用户昵称已存在
            UserId = self.CreateUser(p)
            if not UserId:
                return -10002002  #注册失败

        try:
            mod_play = Gcore.getMod('Player', uid=UserId)
            userData = mod_play.PlayerInfo()

            try:
                Gcore.getMod('Request', UserId).CreatedPlayer(AccountId)
            except Exception, e:
                print '通知总服已创建号失败', e

        except Exception, e:
            userData = {}
            print '登陆失败,', e
            return -10002003
Example #5
0
    def CreateRole(self,p={}):
        '''注册用户 by zhanggh'''
        AccountId = p.get('TotalServiceId') 
        nickName = p.get('NickName')
        camp = p.get('UserCamp')
        userIcon = p.get('UserIcon')
        OldAccount = p.get('OldAccount') #是否老用户

        
        if (not AccountId) or (not nickName) or (not camp) or (not userIcon):
            return -10002999 #参数错误
        
        PlayerCfg = Gcore.loadCfg(Gcore.defined.CFG_PLAYER)
        nickNameMin = PlayerCfg.get('NickNameMin')
        nickNameMax = PlayerCfg.get('NickNameMax')
        
        flag=filterInput(nickName,nickNameMin,nickNameMax)
        if flag==-1:
            return -10002993#字数字数限制
        elif flag==-2:
            return -10002991#特殊字符
        elif flag==-3:
            return -10002992#敏感字
        
        if camp not in [1,2,3]:
            return -10002004#阵营不正确
        
        if userIcon not in [1,2,3,4,5]:
            return -10002005#头像不正确
        
        print 'CheckNickName',flag
        
        #获取用户ID,暂时没有角色UserId才能注册
        UserId = self.getUserIdByAccount(AccountId)
        if not UserId:#没有用户注册一个,建立AccountId与Uid关系,创建用户
            #验证用户昵称
            hasSameName = self.db.out_field('tb_user','Count(1)',"NickName='%s'"%nickName)
            if hasSameName:
                return -10002001#用户昵称已存在
            UserId = self.CreateUser(p)
            if not UserId:
                return -10002002#注册失败

        try:
            mod_play = Gcore.getMod('Player', uid=UserId) 
            userData = mod_play.PlayerInfo()
            
            try:
                Gcore.getMod('Request', UserId).CreatedPlayer(AccountId)
            except Exception,e:
                print '通知总服已创建号失败',e
            
        except Exception, e:
            userData = {}
            print '登陆失败,', e
            return -10002003
Example #6
0
    def CreateClub(self,p={}):
        '''创建军团
        @logoId :1-6
        '''
        optId = 15060
        CfgClub = Gcore.loadCfg(defined.CFG_BUILDING_CLUB)
        
        s_Name = p.get('ClubName')
        LogoId = p.get('LogoId')
        i_Min = CfgClub.get('ClubNameLimitMin')
        i_Max = CfgClub.get('ClubNameLimitMax')
    
        flag = com.filterInput(s_Name, i_Min, i_Max)
        if flag == -1:
            return Gcore.error(optId, -15060993) #长度不符合要求
        elif flag == -2:
            return Gcore.error(optId, -15060992) #不能含有敏感字符
        building = self.mod.getClubBuildingInfo()
        if building is None:
            return  Gcore.error(optId,-15060901)#外史院建筑不存在
        MyClubId = self.mod.getUserClubId()
        if MyClubId:
            return Gcore.error(optId, -15060001) #你已加入军团,不能创建
        
        if self.mod.hadSameName(s_Name):
            return Gcore.error(optId, -15060002) #该军团名称已存在
            

        #开始支付
        CoinType = CfgClub.get('ClubCreateCostType')
        CoinValue = CfgClub.get('ClubCreateCost')
        
        modCoin = Gcore.getMod('Coin',self.uid)
        classMethod = self.__class__.__name__+'.CreateClub'
        result = modCoin.PayCoin(optId, CoinType, CoinValue, classMethod, p)
        
        
        if result < 0:
            return Gcore.error(optId,-15060995) #支付失败
        else:
            ClubId = self.mod.createClub(LogoId,s_Name) #创建军团
            Gcore.setUserData(self.uid, {'ClubId':ClubId})#更新用户缓存
            body = {'ClubId':ClubId}
            recordData = {'uid':self.uid,'ValType':0,'Val':1}#任务
            return Gcore.out(optId,body,mission=recordData)
Example #7
0
    def CreateClub(self, p={}):
        '''创建军团
        @logoId :1-6
        '''
        optId = 15060
        CfgClub = Gcore.loadCfg(defined.CFG_BUILDING_CLUB)

        s_Name = p.get('ClubName')
        LogoId = p.get('LogoId')
        i_Min = CfgClub.get('ClubNameLimitMin')
        i_Max = CfgClub.get('ClubNameLimitMax')

        flag = com.filterInput(s_Name, i_Min, i_Max)
        if flag == -1:
            return Gcore.error(optId, -15060993)  #长度不符合要求
        elif flag == -2:
            return Gcore.error(optId, -15060992)  #不能含有敏感字符
        building = self.mod.getClubBuildingInfo()
        if building is None:
            return Gcore.error(optId, -15060901)  #外史院建筑不存在
        MyClubId = self.mod.getUserClubId()
        if MyClubId:
            return Gcore.error(optId, -15060001)  #你已加入军团,不能创建

        if self.mod.hadSameName(s_Name):
            return Gcore.error(optId, -15060002)  #该军团名称已存在

        #开始支付
        CoinType = CfgClub.get('ClubCreateCostType')
        CoinValue = CfgClub.get('ClubCreateCost')

        modCoin = Gcore.getMod('Coin', self.uid)
        classMethod = self.__class__.__name__ + '.CreateClub'
        result = modCoin.PayCoin(optId, CoinType, CoinValue, classMethod, p)

        if result < 0:
            return Gcore.error(optId, -15060995)  #支付失败
        else:
            ClubId = self.mod.createClub(LogoId, s_Name)  #创建军团
            Gcore.setUserData(self.uid, {'ClubId': ClubId})  #更新用户缓存
            body = {'ClubId': ClubId}
            recordData = {'uid': self.uid, 'ValType': 0, 'Val': 1}  #任务
            return Gcore.out(optId, body, mission=recordData)
Example #8
0
 def checkNickNameValid(self,p={}):
     '''验证昵称合法性'''
     optId = 10005
     nickName = p.get('NickName')
     PlayerCfg = Gcore.loadCfg(Gcore.defined.CFG_PLAYER)
     nickNameMin = PlayerCfg.get('NickNameMin')
     nickNameMax = PlayerCfg.get('NickNameMax')
     
     flag=filterInput(nickName,nickNameMin,nickNameMax)
     if flag==-1:
         return Gcore.error(optId,-10005993)#字数字数限制
     elif flag==-2:
         return Gcore.error(optId,-10005991)#特殊字符
     elif flag==-3:
         return Gcore.error(optId,-10005992)#敏感字
     #验证用户昵称
     hasSameName = self.db.out_field('tb_user','Count(1)',"NickName='%s'"%nickName)
     if hasSameName:
         return Gcore.error(optId,-10005001)#用户昵称已存在
     return Gcore.out(optId,{})
Example #9
0
    def checkNickNameValid(self, p={}):
        '''验证昵称合法性'''
        optId = 10005
        nickName = p.get('NickName')
        PlayerCfg = Gcore.loadCfg(Gcore.defined.CFG_PLAYER)
        nickNameMin = PlayerCfg.get('NickNameMin')
        nickNameMax = PlayerCfg.get('NickNameMax')

        flag = filterInput(nickName, nickNameMin, nickNameMax)
        if flag == -1:
            return Gcore.error(optId, -10005993)  #字数字数限制
        elif flag == -2:
            return Gcore.error(optId, -10005991)  #特殊字符
        elif flag == -3:
            return Gcore.error(optId, -10005992)  #敏感字
        #验证用户昵称
        hasSameName = self.db.out_field('tb_user', 'Count(1)',
                                        "NickName='%s'" % nickName)
        if hasSameName:
            return Gcore.error(optId, -10005001)  #用户昵称已存在
        return Gcore.out(optId, {})
Example #10
0
    def say(self, optId, channel, content, toName=None):
        #fields = ['NickName', 'VipLevel', 'UserCamp', 'UserLevel']
        #playInfo = self.getUserInfo(fields)
        channel_list = Gcore.loadCfg(CFG_CHANNEL)['Channel']
        if channel in channel_list:
            forbiddenEndTime = self.db.out_field('tb_forbidden_chat',
                                                 'ForbiddenEndTime',
                                                 'Userid=%s' % self.uid)
            if forbiddenEndTime and forbiddenEndTime > int(time.time()):
                return -8
        playInfo = Gcore.StorageUser.get(self.uid)
        if channel not in (5, 6, 7, 8, 9):
            if self.isLimitTime(self.getUserInfo('UserLevel'), channel):
                return -1  #聊天间隔限制
            msgBody = filterInput(content,
                                  i_Min=1,
                                  i_Max=90,
                                  b_Replace=True,
                                  b_chat=True)
        else:
            msgBody = content  #管理员发布的消息不进行过滤

        if not msgBody or int == type(msgBody):
            return -2  #消息未通过验证

        if channel == 1:  #世界
            users = [
                k for k in Gcore.StorageUser
                if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')
            ]
            data = {
                'PlayerId': self.uid,
                'Channel': channel,
                'Content': msgBody,
                'PlayerName': playInfo['NickName'],
                'VIP': playInfo['VipLevel']
            }

        elif channel == 2:  #势力
            users = [ k for k in Gcore.StorageUser\
                   if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel') and Gcore.StorageUser[k]['UserCamp'] == self.getUserCamp() ]
            data = {
                'PlayerId': self.uid,
                'Channel': channel,
                'Content': msgBody,
                'PlayerName': playInfo['NickName'],
                'VIP': playInfo['VipLevel']
            }

        elif channel == 3:  #军团
            if not playInfo['ClubId'] or playInfo['ClubId'] == 0:
                return -5
            users = [ k for k in Gcore.StorageUser\
                   if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel') and Gcore.StorageUser[k]['ClubId'] == playInfo['ClubId'] ]
            data = {
                'PlayerId': self.uid,
                'Channel': channel,
                'Content': msgBody,
                'PlayerName': playInfo['NickName'],
                'VIP': playInfo['VipLevel']
            }

        elif channel == 4:  #私聊
            if playInfo and toName == playInfo['NickName']:
                return -6
            users = [k for k in Gcore.StorageUser\
                   if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel') and Gcore.StorageUser[k]['NickName'] == toName and k != self.uid]
            if not users:
                return -3
            touserId = users[0]
            users.append(self.uid)
            print 'Users', users
            data = {
                'PlayerId': self.uid,
                'Channel': channel,
                'Content': msgBody,
                'PlayerName': playInfo['NickName'],
                'ToName': toName,
                'ToUserId': touserId
            }

        elif channel == 5:  #系统
            users = [
                k for k in Gcore.StorageUser
                if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')
            ]
            data = {'PlayerId': 0, 'Channel': channel, 'Content': msgBody}

        elif channel == 6:  #喇叭
            users = [
                k for k in Gcore.StorageUser
                if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')
            ]
            data = {
                'PlayerId': self.uid,
                'Channel': channel,
                'Content': msgBody,
                'PlayerName': playInfo['NickName'],
                'VIP': playInfo['VipLevel']
            }
            modItem = Gcore.getMod('Item', self.uid)
            re = modItem.useItem(optId, 'say', {}, 801)
            #if not Gcore.TEST and re < 0:
            if re < 0:
                return -4

        elif channel == 7:  #GM发布公告
            userType = self.getUserInfo('UserType')
            if userType != 1:
                return -7  #非GM不允许发布公告
            users = [
                k for k in Gcore.StorageUser
                if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')
            ]
            data = {'Channel': channel, 'Content': msgBody}

        elif channel == 8:  #活动
            userType = self.getUserInfo('UserType')
            if userType != 1:
                return -7  #非GM不允许发布活动消息
            users = [
                k for k in Gcore.StorageUser
                if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')
            ]
            data = {'Channel': channel, 'Content': msgBody}

        elif channel == 9:  #广播
            userType = self.getUserInfo('UserType')
            if userType != 1:
                return -7  #非GM不允许发布广播
            users = [
                k for k in Gcore.StorageUser
                if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')
            ]
            data = {'Channel': channel, 'Content': msgBody}

        else:
            return -5

        Gcore.push(110, users, data)
        self.lastspeaktime = time.time()

        return data
Example #11
0
    def InsMessage(self, param={}):
        '''
                    发送邮件
        '''
        import sys
        reload(sys)
        sys.setdefaultencoding('utf8')

        optId = 18006

        toUserNickNames = param['ToUserNickNames']  #收件人昵称字符串
        subject = param['Subject']
        content = param['Content']

        mailCfg = Gcore.loadCfg(Gcore.defined.CFG_MAIL)
        subjectMin = mailCfg['SubjectMin']  #主题最小字符数
        subjectMax = mailCfg['SubjectMax']  #主题最大字符数
        contentMin = mailCfg['ContentMin']
        contentMax = mailCfg['ContentMax']
        toUserMax = mailCfg['MailSendMax']  #同时发送邮件最大数量

        toUserNickNames = escapeSplit(toUserNickNames)  #解析昵称字符串
        inexistUserNickNames = self.mod.inexistNickName(
            toUserNickNames)  #过滤收件人

        toUserIds = self.mod.getToUserId(toUserNickNames)  #根据昵称,得到玩家id

        #最多同时发送邮件给五个玩家,最少一个
        numToUserId = len(toUserIds)
        if numToUserId > toUserMax:
            #不能超过5个玩家
            return Gcore.error(optId, -18006001)

        #过滤主题和邮件内容
        subject = filterInput(subject,
                              subjectMin,
                              subjectMax,
                              b_Replace=True,
                              b_chat=True)
        if subject == -1:
            return Gcore.error(optId, -18006993)  #长度不符合要求
        if subject == -2:
            return Gcore.error(optId, -18006991)  #特殊字符
        content = filterInput(content,
                              contentMin,
                              contentMax,
                              b_Replace=True,
                              b_chat=True)
        if content == -1:
            return Gcore.error(optId, -18006993)  #长度不符合要求
        if content == -2:
            return Gcore.error(optId, -18006991)  #特殊字符
#        if not filterInput(subject,subjectMin,subjectMax) and not filterInput(content,contentMin,contentMax):
#            return Gcore.error(optId, -18006002) #不满足要求,长度,特殊字符,敏感字符'
        if self.uid in toUserIds:
            return Gcore.error(optId, -18006002)  #不能发信息给自己
        param['ToUserIds'] = toUserIds
        result = self.mod.sendMail(toUserIds, subject, content, 2)

        #        body ={'result':result,'inexistUserId':inexistUserId}
        body = {'result': result, 'InexistNames': inexistUserNickNames}

        recordData = {
            'uid': self.uid,
            'ValType': numToUserId,
            'Val': 1
        }  #成就,任务记录
        return Gcore.out(optId, body=body, mission=recordData)
Example #12
0
    def say(self, optId, channel, content, toName = None):
        #fields = ['NickName', 'VipLevel', 'UserCamp', 'UserLevel']
        #playInfo = self.getUserInfo(fields)
        channel_list = Gcore.loadCfg(CFG_CHANNEL)['Channel']
        if channel in channel_list:
            forbiddenEndTime = self.db.out_field('tb_forbidden_chat', 'ForbiddenEndTime', 'Userid=%s'%self.uid)
            if forbiddenEndTime and forbiddenEndTime > int(time.time()):
                return -8
        playInfo = Gcore.StorageUser.get(self.uid)
        if channel not in (5, 6, 7, 8, 9):
            if self.isLimitTime(self.getUserInfo('UserLevel'), channel):
                return -1   #聊天间隔限制
            msgBody = filterInput(content,i_Min = 1, i_Max = 90, b_Replace = True,b_chat = True)
        else:
            msgBody = content   #管理员发布的消息不进行过滤    

        if not msgBody or int == type(msgBody):
            return -2       #消息未通过验证
        
        if channel == 1:    #世界
            users=[k for k in Gcore.StorageUser if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')]
            data={'PlayerId':self.uid, 'Channel':channel, 'Content':msgBody, 'PlayerName':playInfo['NickName'], 'VIP':playInfo['VipLevel']}
            
        elif channel == 2:  #势力
            users = [ k for k in Gcore.StorageUser\
                   if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel') and Gcore.StorageUser[k]['UserCamp'] == self.getUserCamp() ]
            data = {'PlayerId':self.uid,'Channel':channel,'Content':msgBody,'PlayerName':playInfo['NickName'],'VIP':playInfo['VipLevel']}
            
        elif channel == 3:  #军团
            if not playInfo['ClubId'] or playInfo['ClubId'] == 0:
                return -5
            users = [ k for k in Gcore.StorageUser\
                   if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel') and Gcore.StorageUser[k]['ClubId'] == playInfo['ClubId'] ]
            data={'PlayerId':self.uid,'Channel':channel,'Content':msgBody,'PlayerName':playInfo['NickName'],'VIP':playInfo['VipLevel']}
            
        elif channel == 4:  #私聊
            if playInfo and toName == playInfo['NickName']:
                return -6
            users = [k for k in Gcore.StorageUser\
                   if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel') and Gcore.StorageUser[k]['NickName'] == toName and k != self.uid]
            if not users:
                return -3
            touserId = users[0]
            users.append(self.uid)
            print 'Users',users
            data = {'PlayerId':self.uid,'Channel':channel,'Content':msgBody,'PlayerName':playInfo['NickName'],'ToName':toName,'ToUserId':touserId}
            
        elif channel == 5:  #系统
            users = [k for k in Gcore.StorageUser if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')]
            data = {'PlayerId':0,'Channel':channel,'Content':msgBody}
            
        elif channel == 6:  #喇叭
            users = [k for k in Gcore.StorageUser if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')]
            data = {'PlayerId':self.uid,'Channel':channel,'Content':msgBody,'PlayerName':playInfo['NickName'],'VIP':playInfo['VipLevel']}
            modItem = Gcore.getMod('Item',self.uid)
            re = modItem.useItem(optId, 'say', {}, 801)
            #if not Gcore.TEST and re < 0:
            if re < 0:
                return -4
            
        elif channel == 7:  #GM发布公告
            userType = self.getUserInfo('UserType')
            if userType != 1:
                return -7   #非GM不允许发布公告
            users = [k for k in Gcore.StorageUser if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')]
            data = {'Channel':channel, 'Content':msgBody}
            
        elif channel == 8:  #活动
            userType = self.getUserInfo('UserType')
            if userType != 1:
                return -7   #非GM不允许发布活动消息
            users = [k for k in Gcore.StorageUser if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')]
            data = {'Channel':channel, 'Content':msgBody}
            
        elif channel == 9:  #广播
            userType = self.getUserInfo('UserType')
            if userType != 1:
                return -7   #非GM不允许发布广播
            users = [k for k in Gcore.StorageUser if Gcore.StorageUser[k] and Gcore.StorageUser[k].get('Channel')]
            data = {'Channel':channel, 'Content':msgBody}
            
        else:
            return -5

        Gcore.push(110, users, data)
        self.lastspeaktime = time.time()
        
        return data