Example #1
0
    def getConfigForClient(self, gameId, userId, clientId):
        clientConf = strutil.cloneData(self._clientConf)
        if clientConf["config"]["firstButton"]["visible"]:
            '''
                处理第1个按钮的todotask
            '''
            todoTask = clientConf["config"]["firstButton"]
            todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(todoTask).newTodoTask(gameId, userId, clientId)
            clientConf["config"]["firstButton"] = todoTaskObj.toDict()
            clientConf["config"]["firstButton"]["visible"] = 1
        else:
            pass

        if clientConf["config"]["secondButton"]["visible"]:
            '''
                处理第2个按钮的todotask
            '''
            todoTask = clientConf["config"]["secondButton"]
            todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(todoTask).newTodoTask(gameId, userId, clientId)
            clientConf["config"]["secondButton"] = todoTaskObj.toDict()
            clientConf["config"]["secondButton"]["visible"] = 1
        else:
            pass
        ftlog.debug("the noticeImg client config : ", clientConf)
        return clientConf
Example #2
0
    def getConfigForClient(self, gameId, userId, clientId):
        '''
            用来对所有的general_btn对应的活动中的按钮
            进行统一管理
        '''
        clientConf = strutil.cloneData(self._clientConf)
        button = clientConf["config"]["button"]
        if button["visible"]:
            # true
            todoTaskDict = button["todoTask"]
            if todoTaskDict:
                todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(
                    todoTaskDict).newTodoTask(gameId, userId, clientId)
                if not todoTaskObj:
                    gotoShopDict = {
                        "typeId": TodoTaskGotoShopFactory.TYPE_ID,
                        "subStore": "coin"
                    }
                    todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(
                        gotoShopDict).newTodoTask(gameId, userId, clientId)

                clientConf["config"]["button"][
                    "todoTask"] = todoTaskObj.toDict()

            return clientConf
        else:
            # false
            pass
Example #3
0
    def getConfigForClient(self, gameId, userId, clientId):
        clientConf = strutil.cloneData(self._clientConf)
        if clientConf["config"]["firstButton"]["visible"]:
            '''
                处理第1个按钮的todotask
            '''
            todoTask = clientConf["config"]["firstButton"]
            todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(
                todoTask).newTodoTask(gameId, userId, clientId)
            clientConf["config"]["firstButton"] = todoTaskObj.toDict()
            clientConf["config"]["firstButton"]["visible"] = 1
        else:
            pass

        if clientConf["config"]["secondButton"]["visible"]:
            '''
                处理第2个按钮的todotask
            '''
            todoTask = clientConf["config"]["secondButton"]
            todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(
                todoTask).newTodoTask(gameId, userId, clientId)
            clientConf["config"]["secondButton"] = todoTaskObj.toDict()
            clientConf["config"]["secondButton"]["visible"] = 1
        else:
            pass
        ftlog.debug("the noticeImg client config : ", clientConf)
        return clientConf
Example #4
0
    def decodeFromDict(self, d):
        self.adsId = d.get('id')
        if not isinstance(self.adsId, int):
            raise TYBizConfException(d, 'TYAds.id must be int')
        self.clickable = d.get('clickable')
        # if self.clickable not in (0, 1):
        #     raise TYBizConfException(d, 'TYAds.clickable must be int int (0,1)')
        self.pic = d.get('pic', '')
        if not isstring(self.pic):
            raise TYBizConfException(d, 'TYAds.pic must be string')

        self.startDT = d.get('startTime')
        if self.startDT is not None:
            self.startDT = datetime.strptime(self.startDT, '%Y-%m-%d %H:%M:%S')
        self.endDT = d.get('endTime')
        if self.endDT is not None:
            self.endDT = datetime.strptime(self.endDT, '%Y-%m-%d %H:%M:%S')

        self.todotasks = []
        for todotask in d.get('todotasks', []):
            self.todotasks.append(
                hallpopwnd.decodeTodotaskFactoryByDict(todotask))

        self.condition = d.get('condition')
        if self.condition is not None:
            self.condition = UserConditionRegister.decodeFromDict(
                self.condition)
        return self
Example #5
0
    def _handleSigninFeeNotEnoughException_V3_772(cls, room, ex, uid, mo):
        payOrder = ex.fee.getParam('payOrder')
        clientId = sessiondata.getClientId(uid)
        ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772", "userId", uid, "fee.itemId=", ex.fee.assetKindId, "fee.params=", ex.fee.params)
        ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772, userId=", uid, "payOrder=", payOrder)

        if payOrder:
            product, _shelves = hallstore.findProductByPayOrder(room.gameId, uid, clientId, payOrder)
            if not product:
                cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.fee.failure, None)
                return

            buyType = ''
            btnTxt = ''
            if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID: # 金币是报名费
                orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType)
                orderShow.setParam('sub_action_btn_text', btnTxt)
                mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, orderShow)
                router.sendToUser(mo, uid)
                return

        ## 其他报名费/gotoshop
        todotask = ex.fee.getParam('todotask')
        todotask_str = None
        button_title = None
        ftlog.debug("groupmatch._handleSigninFeeNotEnoughException_V3_772, userId=", uid, "todotask=", todotask)
        if todotask:
            button_title = "去商城"
            todotask_str = hallpopwnd.decodeTodotaskFactoryByDict(todotask).newTodoTask(room.gameId, uid, clientId).toDict()
        cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.fee.failure, todotask_str, button_title)
Example #6
0
 def _decodeFromDictImpl(self, d):
     from hall.entity import hallpopwnd
     self._cycle = TimeCycleRegister.decodeFromDict(d.get('cycle'))
     self._condition = UserConditionRegister.decodeFromDict(
         d.get('condition'))
     playRounds = d.get('playRounds', [])
     if not playRounds or not isinstance(playRounds, list):
         raise TYBizConfException(
             d, 'PlayGameTodotask.playRounds must be not empty list')
     self._playRounds = []
     for item in playRounds:
         if not item or not isinstance(item, dict):
             raise TYBizConfException(
                 d,
                 'PlayGameTodotask.playRounds.item must be not empty dict')
         playRound = item.get('playRound')
         if not isinstance(playRound, int):
             raise TYBizConfException(
                 d,
                 'PlayGameTodotask.playRounds.item.playRound must be int')
         todotaskFac = hallpopwnd.decodeTodotaskFactoryByDict(
             item.get('todotask'))
         self._playRounds.append((playRound, todotaskFac))
     self._hallGameIds = d.get('hallGameIds', [])
     if not isinstance(self._hallGameIds, list):
         raise TYBizConfException(
             d, 'PlayGameTodotask.hallGameIds must be list')
     for hallGameId in self._hallGameIds:
         if not isinstance(hallGameId, int):
             raise TYBizConfException(
                 d, 'PlayGameTodotask.hallGameIds must be int list')
     return self
Example #7
0
 def _decodeFromDictImpl(self, d):
     self.freshTip = d.get('freshTip', False)
     dict_todo = d.get('todotask')
     if dict_todo:
         self._todo_task_factory = hallpopwnd.decodeTodotaskFactoryByDict(
             dict_todo)
         self.lblEnter = d.get('lblEnter')
Example #8
0
 def getConfigForClient(self, gameId, userId, clientId):
     conf = copy.deepcopy(self._clientConf)
     button = conf["config"]["button"]
     if button["visible"]:
         todoTaskDict = button["todoTask"]
         if todoTaskDict:
             todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(todoTaskDict).newTodoTask(gameId, userId, clientId)
             button["todoTask"] = todoTaskObj.toDict()
     else:
         del conf["config"]["button"]
     return conf
Example #9
0
 def decodeFromDict(self, d):
     self.promotionId = d.get('promotionId')
     self.displayName = d.get('displayName')
     self.url = d.get('url')
     self.defaultRes = d.get('defaultRes', None)
     self.animate = d.get('animate')
     self.todotasks = []
     for todotaskDict in d.get('todotasks', []):
         self.todotasks.append(hallpopwnd.decodeTodotaskFactoryByDict(todotaskDict))
     self.redPoint = UserConditionRegister.decodeList(d.get('redPoint', []))
     return self
Example #10
0
 def getConfigForClient(self, gameId, userId, clientId):
     conf = copy.deepcopy(self._clientConf)
     button = conf["config"]["button"]
     if button["visible"]:
         todoTaskDict = button["todoTask"]
         if todoTaskDict:
             todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(todoTaskDict).newTodoTask(gameId, userId, clientId)
             button["todoTask"] = todoTaskObj.toDict()
     else:
         del conf["config"]["button"]
     return conf
    def fromDict(self, d):
        self.pic = d.get('pic', '')
        if not isstring(self.pic):
            raise TYBizConfException(d, 'RPAct.pic must be string')

        todotaskD = d.get('todotask')
        if todotaskD:
            self.todotaskFac = hallpopwnd.decodeTodotaskFactoryByDict(
                todotaskD)

        return self
Example #12
0
 def decodeFromDict(self, d):
     self.promotionId = d.get('promotionId')
     self.displayName = d.get('displayName')
     self.url = d.get('url')
     self.defaultRes = d.get('defaultRes', None)
     self.animate = d.get('animate')
     self.todotasks = []
     for todotaskDict in d.get('todotasks', []):
         self.todotasks.append(
             hallpopwnd.decodeTodotaskFactoryByDict(todotaskDict))
     self.redPoint = UserConditionRegister.decodeList(d.get('redPoint', []))
     return self
Example #13
0
 def newTodoTask(self, gameId, userId, clientId, **kwargs):
     from hall.entity import hallpopwnd
     ret = TodoTask(self.action)
     if self.params:
         for k, v in self.params.iteritems():
             ret.setParam(k, v)
     if self.actions:
         for action in self.actions:
             name = action.get('name')
             fac = hallpopwnd.decodeTodotaskFactoryByDict(action.get('action'))
             todotask = fac.newTodoTask(gameId, userId, clientId, **kwargs)
             ret.setParam(name, todotask)
     return ret
Example #14
0
def newTodoTask(self, gameId, userId, clientId, timestamp, **kwargs):
    subMemberStatus = kwargs.get(
        'subMemberStatus') or hallsubmember.loadSubMemberStatus(userId)
    if subMemberStatus.isSub:
        todotask = TodoTaskMemberBuy(self.descForMember, self.pic)
        todotask.setParam('tip_bottom', self.tipForSubMember)
        return todotask

    memberInfo = kwargs.get('memberInfo') or hallitem.getMemberInfo(
        userId, timestamp)
    remainDays = memberInfo[0]
    todotask = None
    subActionText = None

    product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId,
                                                 self.payOrder)

    if not product:
        return None

    if remainDays > 0:
        todotask = TodoTaskMemberBuy(self.descForMember, self.pic)
        tipForMember = strutil.replaceParams(self.tipForMember,
                                             {'remainDays': str(remainDays)})
        todotask.setParam('tip_bottom_left', tipForMember)
        todotask.setParam('sub_action_text', self.subActionTextForMember)
    else:
        price = product.price
        priceUnits = '元'
        if product.buyType == 'consume':
            price = product.priceDiamond
            priceUnits = '钻石'
        params = {
            'product.price': str(price),
            'product.priceUnits': priceUnits
        }
        if product.content and product.content.desc:
            params['product.content.desc'] = product.content.desc
        desc = strutil.replaceParams(self.desc, params)
        todotask = TodoTaskMemberBuy(desc, self.pic)
        todotask.setSubText(self.subActionText)
        todotask.setParam('sub_action_text', self.subActionText)

    todotask.setSubCmdWithText(TodoTaskPayOrder(product), subActionText)

    if remainDays <= 0 and self.closeAction:
        closeAction = decodeTodotaskFactoryByDict(
            self.closeAction).newTodoTask(gameId, userId, clientId, **kwargs)
        if closeAction:
            todotask.setParam('sub_action_close', closeAction)
    return todotask
Example #15
0
    def decodeFromDict(self, d):
        self.desc = d.get('desc', '')
        self.btnText = d.get('btnText', '')
        self.hasMark = d.get('hasMark', False)
        self.enable = d.get('enable', True)
        self.visible = d.get('visible', True)

        self.conditionList = UserConditionRegister.decodeList(d.get('conditions', []))

        self.todotaskList = []
        for todotaskDict in d.get('todotasks', []):
            self.todotaskList.append(hallpopwnd.decodeTodotaskFactoryByDict(todotaskDict))

        return self
Example #16
0
    def _handleSigninFeeNotEnoughException_V3_772(self, ex, userId, mo):
        payOrder = ex.fee.getParam('payOrder')
        clientId = sessiondata.getClientId(userId)
        if ftlog.is_debug():
            ftlog.debug('DizhuCtrlRoomGroupMatch._handleSigninFeeNotEnoughException_V3_772',
                        'roomId=', self.roomId,
                        'userId=', userId,
                        'feeItem=', ex.fee.assetKindId,
                        'feeParams=', ex.fee.params)
        if payOrder:
            product, _shelves = hallstore.findProductByPayOrder(self.gameId, userId, clientId, payOrder)
            if not product:
                self.sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.fee.failure, None)
                return

            buyType = ''
            btnTxt = ''
            if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID or ex.fee.assetKindId == hallitem.ASSET_DIAMOND_KIND_ID:
                buyType = 'charge'
                btnTxt = '确定'
            orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType, ex.fee.count, ex.fee.assetKindId)
            orderShow.setParam('sub_action_btn_text', btnTxt)
            mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, orderShow)
            router.sendToUser(mo, userId)
            return

        ## 其他报名费/gotoshop
        title = '报名失败'
        todotask = ex.fee.getParam('todotask')
        todotask_str = None
        button_title = None
        if todotask:
            button_title = "去商城"
            todotaskObj = hallpopwnd.decodeTodotaskFactoryByDict(todotask).newTodoTask(self.gameId, userId, clientId)
            if todotaskObj:
                todotask_str = todotaskObj.toDict()
        itemCount = 0
        itemName = ''
        itemDes = ''
        itemUrl = ''
        if 'item' in ex.fee.assetKindId and ex.fee.count > 0:
            assetKind = hallitem.itemSystem.findAssetKind(ex.fee.assetKindId)
            if assetKind:
                title = '道具不足'
                itemCount = ex.fee.count
                itemName = assetKind.displayName
                itemDes = assetKind.desc
                itemUrl = assetKind.pic
        self.sendDizhuFailureMsg(self.gameId, userId, title, ex.fee.failure, todotask_str, button_title, itemCount,
                                 itemName, itemDes, itemUrl)
Example #17
0
    def getConfigForClient(self, gameId, userId, clientId):
        '''
            用来对所有的general_btn对应的活动中的按钮
            进行统一管理
        '''
        clientConf = strutil.cloneData(self._clientConf)
        button = clientConf["config"]["button"]
        if button["visible"]:
            # true
            todoTaskDict = button["todoTask"]
            if todoTaskDict:
                todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(todoTaskDict).newTodoTask(gameId, userId, clientId)
                if not todoTaskObj:
                    gotoShopDict = {"typeId": TodoTaskGotoShopFactory.TYPE_ID, "subStore": "coin"}
                    todoTaskObj = hallpopwnd.decodeTodotaskFactoryByDict(gotoShopDict).newTodoTask(gameId, userId,
                                                                                                   clientId)

                clientConf["config"]["button"]["todoTask"] = todoTaskObj.toDict()

            return clientConf
        else:
            # false
            pass
Example #18
0
 def handleItemActionConditionException(self, itemId, gameId, userId, clientId, e):
     showInfo = TodoTaskShowInfo(e.message)
     payOrder = e.condition.getParam('payOrder')
     if payOrder:
         product, shelves = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
         if product:
             showInfo.setSubCmd(TodoTaskGotoShop(shelves.name))
     else:
         todotask = e.condition.getParam('todotask')
         if todotask:
             factory = hallpopwnd.decodeTodotaskFactoryByDict(todotask)
             if factory:
                 todotask = factory.newTodoTask(gameId, userId, clientId)
                 TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
                 return
     TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
Example #19
0
    def decodeFromDict(self, d):
        self.desc = d.get('desc', '')
        self.btnText = d.get('btnText', '')
        self.hasMark = d.get('hasMark', False)
        self.enable = d.get('enable', True)
        self.visible = d.get('visible', True)

        self.conditionList = UserConditionRegister.decodeList(
            d.get('conditions', []))

        self.todotaskList = []
        for todotaskDict in d.get('todotasks', []):
            self.todotaskList.append(
                hallpopwnd.decodeTodotaskFactoryByDict(todotaskDict))

        return self
Example #20
0
 def handleItemActionConditionException(self, itemId, gameId, userId,
                                        clientId, e):
     showInfo = TodoTaskShowInfo(e.message)
     payOrder = e.condition.getParam('payOrder')
     if payOrder:
         product, shelves = hallstore.findProductByPayOrder(
             gameId, userId, clientId, payOrder)
         if product:
             showInfo.setSubCmd(TodoTaskGotoShop(shelves.name))
     else:
         todotask = e.condition.getParam('todotask')
         if todotask:
             factory = hallpopwnd.decodeTodotaskFactoryByDict(todotask)
             if factory:
                 todotask = factory.newTodoTask(gameId, userId, clientId)
                 TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
                 return
     TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
Example #21
0
def maekItem(ad, gameId, userId, clientId):
    item = {}
    item['todotasks'] = []

    for key in ad:
        if key != 'todotasks':
            item[key] = ad[key]

        # make the todotask
        todostasks = []
        for task in ad.get('todotasks', []):
            taskFactory = hallpopwnd.decodeTodotaskFactoryByDict(task)
            dstTask = taskFactory.newTodoTask(gameId, userId, clientId)
            todostasks.append(dstTask)

        item['todotasks'] = TodoTaskHelper.encodeTodoTasks(todostasks)

    return item
    def decodeFromDict(self, d):
        self.kindId = d.get('kindId')
        if not isinstance(self.kindId, int):
            raise TYBizConfException(d, 'RPTaskKind.kindId must be int')

        self.name = d.get('name')
        if not isstring(self.name):
            raise TYBizConfException(d, 'RPTaskKind.name must be string')

        self.count = d.get('count')
        if not isinstance(self.count, int):
            raise TYBizConfException(d, 'RPTaskKind.count must be int')

        self.desc = d.get('desc', '')
        if not isstring(self.desc):
            raise TYBizConfException(d, 'RPTaskKind.desc must be string')

        self.pic = d.get('pic', '')
        if not isstring(self.pic):
            raise TYBizConfException(d, 'RPTaskKind.pic must be string')

        inviterReward = d.get('inviterReward', 0)
        if not isinstance(inviterReward, int) or inviterReward < 0:
            raise TYBizConfException(
                d, 'RPTaskKind.inviterReward must be int >= 0')
        self.inviterReward = inviterReward

        rewardContent = d.get('rewardContent')
        if rewardContent:
            self.rewardContent = TYContentRegister.decodeFromDict(
                rewardContent)
            self.rewardMail = d.get('rewardMail', '')
            if not isstring(self.rewardMail):
                raise TYBizConfException(
                    d, 'RPTaskKind.rewardMail must be string')

        self.inspector = TYTaskInspectorRegister.decodeFromDict(
            d.get('inspector'))
        todotask = d.get('todotask')
        if todotask:
            self.todotaskFac = hallpopwnd.decodeTodotaskFactoryByDict(todotask)
        self._decodeFromDictImpl(d)
        return self
Example #23
0
def newTodoTask(self, gameId, userId, clientId, timestamp, **kwargs):
    subMemberStatus = kwargs.get('subMemberStatus') or hallsubmember.loadSubMemberStatus(userId)
    if subMemberStatus.isSub:
        todotask = TodoTaskMemberBuy(self.descForMember, self.pic)
        todotask.setParam('tip_bottom', self.tipForSubMember)
        return todotask

    memberInfo = kwargs.get('memberInfo') or hallitem.getMemberInfo(userId, timestamp)
    remainDays = memberInfo[0]
    todotask = None
    subActionText = None

    product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId, self.payOrder)

    if not product:
        return None

    if remainDays > 0:
        todotask = TodoTaskMemberBuy(self.descForMember, self.pic)
        tipForMember = strutil.replaceParams(self.tipForMember, {'remainDays': str(remainDays)})
        todotask.setParam('tip_bottom_left', tipForMember)
        todotask.setParam('sub_action_text', self.subActionTextForMember)
    else:
        price = product.price
        priceUnits = '元'
        if product.buyType == 'consume':
            price = product.priceDiamond
            priceUnits = '钻石'
        params = {'product.price': str(price), 'product.priceUnits': priceUnits}
        if product.content and product.content.desc:
            params['product.content.desc'] = product.content.desc
        desc = strutil.replaceParams(self.desc, params)
        todotask = TodoTaskMemberBuy(desc, self.pic)
        todotask.setSubText(self.subActionText)
        todotask.setParam('sub_action_text', self.subActionText)

    todotask.setSubCmdWithText(TodoTaskPayOrder(product), subActionText)

    if remainDays <= 0 and self.closeAction:
        closeAction = decodeTodotaskFactoryByDict(self.closeAction).newTodoTask(gameId, userId, clientId, **kwargs)
        if closeAction:
            todotask.setParam('sub_action_close', closeAction)
    return todotask
Example #24
0
    def _handleSigninFeeNotEnoughException_V3_772(self, ex, userId, mo):
        payOrder = ex.fee.getParam('payOrder')
        clientId = sessiondata.getClientId(userId)
        if ftlog.is_debug():
            ftlog.debug(
                'DizhuErdayiMatchCtrlRoomProtocol._handleSigninFeeNotEnoughException_V3_772',
                'roomId=', self.roomId, 'userId=', userId, 'feeItem=',
                ex.fee.assetKindId, 'feeParams=', ex.fee.params)
        if payOrder:
            product, _shelves = hallstore.findProductByPayOrder(
                self.gameId, userId, clientId, payOrder)
            if not product:
                self._sendDizhuFailureMsg(self.gameId, userId, '报名失败',
                                          ex.fee.failure, None)
                return

            buyType = ''
            btnTxt = ''
            if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID or ex.fee.assetKindId == hallitem.ASSET_DIAMOND_KIND_ID:
                buyType = 'charge'
                btnTxt = '确定'
            orderShow = TodoTaskOrderShow.makeByProduct(
                ex.fee.failure, '', product, buyType)
            orderShow.setParam('sub_action_btn_text', btnTxt)
            mo = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, orderShow)
            router.sendToUser(mo, userId)
            return

        ## 其他报名费/gotoshop
        todotask = ex.fee.getParam('todotask')
        todotask_str = None
        button_title = None
        if todotask:
            button_title = "去商城"
            todotaskObj = hallpopwnd.decodeTodotaskFactoryByDict(
                todotask).newTodoTask(self.gameId, userId, clientId)
            if todotaskObj:
                todotask_str = todotaskObj.toDict()
        self._sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.fee.failure,
                                  todotask_str, button_title)
Example #25
0
    def decodeFromDict(self, d):
        self.adsId = d.get('id')
        if not isinstance(self.adsId, int):
            raise TYBizConfException(d, 'TYAds.id must be int')
        self.clickable = d.get('clickable')
        # if self.clickable not in (0, 1):
        #     raise TYBizConfException(d, 'TYAds.clickable must be int int (0,1)')
        self.pic = d.get('pic', '')
        if not isstring(self.pic):
            raise TYBizConfException(d, 'TYAds.pic must be string')

        self.startDT = d.get('startTime')
        if self.startDT is not None:
            self.startDT = datetime.strptime(self.startDT, '%Y-%m-%d %H:%M:%S')
        self.endDT = d.get('endTime')
        if self.endDT is not None:
            self.endDT = datetime.strptime(self.endDT, '%Y-%m-%d %H:%M:%S')

        self.todotasks = []
        for todotask in d.get('todotasks', []):
            self.todotasks.append(hallpopwnd.decodeTodotaskFactoryByDict(todotask))
        return self
Example #26
0
def send_todotask(gameid, typeid, clientid, userId, text, d, duration=0, fromuid=None, **todotask_kwarg):
    todo_task = hallpopwnd.decodeTodotaskFactoryByDict(d).newTodoTask(gameid, userId, clientid, **todotask_kwarg)
    attach = AttachmentTodoTask(todo_task, duration)
    message.send(gameid, typeid, userId, text, fromuid, attach)